類型轉換:
字符串轉整型:System.Int32.Parse(字符串) 字符串轉日期:日期字符串.ToString("yyyy-MM-dd hh:mm:ss")
下拉框賦值
ArrayList list = new ArrayList(); list.Add(new DictionaryEntry(1, "進入")); list.Add(new DictionaryEntry(2, "離開")); comboBox1.DataSource = list; comboBox1.DisplayMember = "Value"; comboBox1.ValueMember = "Key";
獲取下拉框的值
string crlb = this.comboBox1.SelectedValue.ToString() +"," + this.comboBox1.Text;
ListView獲取CheckBox為選中狀態的Item,以及刪除Item
for (int i = 0; i < this.listView2.Items.Count; i++) { if (listView2.Items[i].Checked == true)// 如果為選中狀態 { ckvalue += this.listView2.Items[i].SubItems[3].Text + ",";// 取值 this.listView2.Items.Remove(this.listView2.Items[i]);// 刪除選中行 } }
List轉為數組
List<ryBean> rys = new List<ryBean>(); ryBean[] rysArr = rys.ToArray();
查看本欄目