简体   繁体   English

如何在Windows应用程序中获取位于DataGridView内的组合框所选项目?

[英]How to get combobox selected item which is inside DataGridView in windows Application?

如何获取CGridbox所选项目在DataGridView内部?

As others have mentioned in the comments, it would be very useful to provide some sort of code example to explain what you're trying to achieve here, as our solutions may differ depending on the desired outcome, however, the standard procedure for retrieving information from a DataGridView is: 正如其他人在评论中提到的那样,提供某种代码示例来解释您在此处试图实现的目标将非常有用,因为我们的解决方案可能会根据所需的结果而有所不同,但是,检索信息的标准过程从DataGridView是:

dataGridView1.SelectedRows[0].Index

Or if you need the indiviual cell, then: 或者,如果您需要单个单元格,则:

dataGridView1.SelectedCells[0].Index

If you're trying to get the string from the ComboBox then something along the lines of this may help you: 如果您尝试从ComboBox获取字符串,那么类似的方法可能会帮助您:

string SelectedText = dataGridView1.Rows[0].Cells[1].FormattedValue.ToString();

You can then proceed to use the information however you please, for example, if you were trying to get the value instead of the string from the ComboBox then you would use .Value instead of using the ToString() conversions. 然后,您可以随意使用该信息,例如,如果尝试从ComboBox获取值而不是字符串,则可以使用.Value而不是ToString()转换。 This is where some information regarding what you're trying to achieve would come in handy. 在这里,有关您要实现的目标的一些信息会派上用场。

Hope this helps 希望这可以帮助

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

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