using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
string s = "你的爱好是:";
public Form1()
{
InitializeComponent();
} private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int style = 0, k = 1; for (int i = 0; i < listBox1.Items.Count; i++)
{
if (listBox1.GetSelected(i))
style = style | k;
else style = style & (~k);
k = k * 2; }
FontStyle m = new FontStyle();
m = (FontStyle)style;
label1.Font = new Font(label1.Font.Name, label1.Font.Size, m); }
}
}
希望大家帮我解释一下红色的语句
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
string s = "你的爱好是:";
public Form1()
{
InitializeComponent();
} private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int style = 0, k = 1; for (int i = 0; i < listBox1.Items.Count; i++)
{
if (listBox1.GetSelected(i))
style = style | k;
else style = style & (~k);
k = k * 2; }
FontStyle m = new FontStyle();
m = (FontStyle)style;
label1.Font = new Font(label1.Font.Name, label1.Font.Size, m); }
}
}
希望大家帮我解释一下红色的语句
解决方案 »
- 搞定了WINFORM下DataGridView底部固定合计行被最后一行遮挡的问题了,发布到这里以备那些有需要的朋友们参考
- WinForm程序 如何解析JSON格式的string?
- WINFORM中,如何实现添加和修改共用一个窗体?
- [求帮助]关于txtbox手工绑定数据源的更新问题.
- WinForm中的一个循环速度好慢
- C#中,sqlserver主键问题
- 请问怎样知道调用的线程已经结束。
- 急急急!!散100分求简单问题!中文XP+中文VS。NET编的界面(FORM)在英文xp下,中文字符不能完全显示出来
- 定义了一个全局变量为什么它的值在下面却是为空的??
- Visual Studio.NET中文版在Windows XP英文版下的乱码问题?
- C#.net如何获得网页中的treeview的当前选中节点的文字传到另一网页上?
- 关于主窗体中嵌入另一个窗体
for (int i = 0; i < listBox1.SelectedIndices.Count; i++)
{
temp = 1;
for (int j = 0; j < listBox1.SelectedIndices[i]; j++)
{
temp *= 2;
}
style += temp;
}
FontStyle m = new FontStyle();
m = (FontStyle)style;
label1.Font = new Font(label1.Font.Name, label1.Font.Size, m);当选中项下标
为0,则style=1
为1,则style=2
为2,则style=4
为3,则style=8正好对应于FontStyle 类型的
Regular 普通文本。
Bold 加粗文本。
Italic 倾斜文本。
Underline 带下划线的文本当选中0和2则style=5
对应于FontStyle 的普通文本+倾斜文本