winform 一些控件的赋值与取值

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)
 
发布了134 篇原创文章 · 获赞 13 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/qq_36074218/article/details/94392154