另外,当DataGridView中的ComboBox中的选定索引发生更改时,如何执行事件?这里,ComboBox是一种列类型.
解决方法
(1) How can I make a specific column uneditable in DataGridView?
在要进行不可编辑的特定列上设置ReadOnly
标志.
dataGridView.Columns["YourColumnName"].ReadOnly = true;
(2) How can I execute an event when the selected index on a ComboBox in the DataGridView changes?
如果它在你的DataGridView中,它不是一个ComboBox;它是一个DataGridViewComboBoxColumn.根据MSDN:
Unlike the ComboBox control,the DataGridViewComboBoxCell does not have Selectedindex and SelectedValue properties. Instead,selecting a value from a drop-down list sets the cell Value property.
这个我不熟悉,因为我自己从未尝试过.您似乎想要订阅EditingControlShowing
事件,然后查看something like this是否适合您(稍微调整一下).
(3) How can I make the header title align in the center?
dataGridView.Columns["YourColumnName"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。