简体   繁体   中英

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:

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:

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. This is where some information regarding what you're trying to achieve would come in handy.

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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