简体   繁体   English

C#使组合框项目记住该单元格的datagridview.cell.value和datagridview.row

[英]C# make combobox items remember datagridview.cell.value and datagridview.row of that cell

I have a Datagridview and 18 comboboxes.Each combobox represents a column of the Datagridview. 我有一个Datagridview和18个组合框。每个组合框代表Datagridview的一列。

The point is: when I select a combobox item in the dropdownlist, I'd like the other comboboxes to select the corresponding item. 关键是:当我在下拉列表中选择一个组合框项目时,我希望其他组合框选择相应的项目。 I believe that to do that I have to make the comboboxes remember the row of the item. 我相信要做到这一点,我必须使组合框记住项目的行。

At first I tried to make a specific class for it but I'm having some trouble. 起初,我尝试为此设置一个特定的类,但是遇到了一些麻烦。 Then thought that I could store the row information into the combobox by putting it into value property. 然后以为可以将行信息放入value属性中,从而将行信息存储到组合框中。 But I'm still having troubles. 但是我仍然有麻烦。

Keeping in mind that trouble won't ever completely leave me, someone has any tips? 要记住,麻烦永远不会完全离开我,有人有什么建议吗?

Thank you all so much. 非常感谢大家。

I would try this: use the SelectIndexChanged on the first combobox and get the line index, after that, change the others combobox index by setting them with the index you found. 我会尝试这样做:在第一个组合框上使用SelectIndexChanged并获取行索引,此后,通过将其他组合框索引设置为找到的索引来更改其他组合框索引。 This is the dumbest approach, then you can improve it. 这是最愚蠢的方法,您可以对其进行改进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM