I am using the below code to get the ID of columns :
DataGridViewSelectedCellCollection DGV =this.dgvSearch.SelectedCells;
for (int i = 0; i <= DGV.Count - 1; i++)
{
string ID = Convert.ToString(dgvSearch.CurrentRow.Cells[0].Value);
MessageBox.Show(ID);
}
I am getting the ID but I want it once foe each column.
How to do it?
Use DataGridViewSelectedRowCollection instead of DataGridViewSelectedCellCollection and loop through the no of rows selected. inside the loop just give the same what u have given. replace this.dgvSearch.SelectedCells with this.dgvSearch.SelectedRows..
update: