C# winfrom中的几个小问题

来源:百度知道 编辑:UC知道 时间:2024/06/08 15:35:55
1.如何设置ComboBox不可输入,只能从下拉列表中选。
2。DataGridView中怎样设置某一列的对齐方式
3。ComboBox中为什么取不到显示的文本,只能取Valuemember中的值。而一般这个里面存储的是编码,我要使这个值同时把文本也存储进去,后面要用。比如我有一个学生编号,sno,和学生姓名sname,怎样把这两个值都绑定到Valuemember中啊?
SelectedText这个不行,取的是空值

1.设置ComboBox1的DropDownStyle 为DropDownList就好了!只能从列表项选择!无法输入!

2.DataGridView1.Columns(列的索引).DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;

3.ComboBox1.text就是当前ComboBox1中的内容!

1、DropDownStyle属性设为ComboBoxStyle.DropDownList
2、DataGridViewCellStyle style = new DataGridViewCellStyle();//先声明一个DataGridViewCellStyle,可以给很多属性赋值,包括对齐
this.dataGridView1.Columns[0].DefaultCellStyle = style;
就可以了
3、ComboBox.SelectedText可以取到文本值

conbobox.enble=fauls;
datagridview,点击编辑。
combobox.text就是combobox的显示文本。
祝你好运

1.DropDownStyle属性设为ComboBoxStyle.DropDownList ;
2.DataGridView1.Columns(0).DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter ;
3.ComboBox1.text就是当前ComboBox1中的内容!

第一个问题 里面有一个属性是可以设置的 但是我英文水平不行
第二个问题 这个好像不能设置的。。。。。如果可以的话那是我水平不行还没发现哈
第3个问题 他里面的那个 IETMS这个里面吧` 反正你输入IE他就能找到了 然后.vales

1.ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList