winform 一些控件的赋值与取值
程序员文章站
2022-06-08 23:45:26
...
1、textBox
赋值:textBox1.Text = “A”;
取值:string A = textBox1.Text;
2、comboBox
赋值:
ArrayList mylist = new ArrayList();
mylist.Add(new DictionaryEntry("1", "正常"));
mylist.Add(new DictionaryEntry("2", "终止"));
comboBox1.DataSource = mylist;
comboBox1.DisplayMember = "Value";
comboBox1.ValueMember = "Key";
取值:comboBox1.SelectedValue = “1”;
3、dateTimePicker
赋值:dateTimePicker1.Value = (DateTime)“2019-05-01”;
取值:string startDate = dateTimePicker1.Value.ToString("yyyy-MM-dd");
4、checkBox
赋值(默认选中):checkBox1.Checked = true;
取值:bool c = checkBox1.Checked (选中为true,不选为false)
下一篇: 用PHP实现图象锐化代码_php技巧