更改 DataGridView 中 ComboBoxColumn 的选择
我有一个包含不同列的 dataGridView 。其中之一是具有默认选择(英语、德语、中文...)的 ComboBoxColumn。我以编程方式将新行添加到我的 datagridview 中。
dataGridView1.Rows.Add(sn, givenName, mail, department, ToDo);
第五列是我的 ComboBoxColumn,当前写为“ToDo”。 我想说应该选择我的comboBoxItems 中的哪一个。例如这样:
dataGridView1.Rows.Add(sn, givenName, mail, department, 1);
现在应该在我的组合框中选择德语。我在 Form1.designer.cs 中设置了项目。
稍后我想获取为每行选择的项目的值。
I have a dataGridView with different columns. One of them is a ComboBoxColumn with default selections (English, German, Chinese...). I add new Rows programmatically to my datagridview.
dataGridView1.Rows.Add(sn, givenName, mail, department, ToDo);
the fifth column is my ComboBoxColumn where currently is written "ToDo".
I would like to say which of my comboBoxItems should be selected. For example like this:
dataGridView1.Rows.Add(sn, givenName, mail, department, 1);
Now should be German selected in my comboBox. I set the Items at Form1.designer.cs.
Later on I would like to get the values which Item is selected for each Row.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该可以说:
请参阅此 MSDN 页面 设置
Items
的示例You should be able to say:
See this MSDN page for an example of setting the
Items
现在您可以从单元格变量访问您的值。
编辑:
当然,Cells[] 中的数字 0 不适合您的示例。
now you can access you values from cell variable.
EDIT:
Ofcourse number 0 in Cells[] is not fitting to your example.