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)
 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章