1. ListBox
属性列表:
SelectionMode 组件中条目的选择类型,即多选(Multiple)、单选(Single)
Rows 列表框中显示总共多少行
Selected 检测条目是否被选中
SelectedItem 返回的类型是ListItem,获得列表框中被选择的条目
Count 列表框中条目的总数
SelectedIndex 列表框中被选择项的索引值
Items 泛指列表框中的所有项,每一项的类型都是ListItem
ListBox.Items.Remove( ListBox.SelectedItem ); //移除选中项
ListBox.SelectedValue //被选中的值
ListBox.Items.Add( "A1 :" + HDid.ToString() ); //动态添加项 String HDid;
switch( ListBox1.SelectValue ) // 分别响应listbox中的选项
ListBox1.Items.Insert( 0 , new ListItem("text","value")); //插入
index = -1;
//将当前条目的文本以及值都保存到一个临时变量里面
ListItem lt=new ListItem (ListBox.SelectedItem.Text,ListBox.SelectedValue);
//被选中的项的值等于上一条或下一条的值
ListBox.Items[ListBox.SelectedIndex].Text=ListBox.Items[ListBox.SelectedIndex + index].Text;
//被选中的项的值等于上一条或下一条的值
ListBox.Items[ListBox.SelectedIndex].Value=ListBox.Items[ListBox.SelectedIndex + index].Value;
//把被选中项的前一条或下一条的值用临时变量中的取代
ListBox.Items[ListBox.SelectedIndex].Test=lt.Test;
//把被选中项的前一条或下一条的值用临时变量中的取代
ListBox.Items[ListBox.SelectedIndex].Value=lt.Value;
//把鼠标指针放到移动后的那项上
ListBox.Items[ListBox.SelectedIndex].Value=lt.Value;
2 picturebox
1)静态加载图片:image属性
2)动态加载图片:
3)适应图片大小:sizemode=stretchimage
三 获取屏幕大小
Rectangle rect = new Rectangle();
rect = Screen.GetWorkingArea(this);
this.Width = rect.Width; //屏幕宽
this.Height = rect.Height; //屏幕高
四 随机数
Random rd = new Random();
int picture_left1 = rd.Next(5,20);
五