简体   繁体   中英

How to check which cell in dataGridView is selected?

I'm want to send more than one mail from selected cells in dataGridView, but don't know how to find out which cells are selected, so the question is how to find out which cells are selected?

Can I make some loop to iterate through cells and test which cell are selected (checked)?

Language c#.

Use the DataGridView.SelectedCells property.

foreach(DataGridViewCell cell in dataGridView.SelectedCells)
{
    //do something
}
DataGridViewSelectedCellCollection selectedCells = myDataGridView.SelectedCells;

请参见以下示例: 如何:在Windows窗体DataGridView控件中获取选定的单元格,行和列

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