+1 vote
46 views

I have a datagridview in c# with rows , i need to bring the item which is select from combobox ..If value of combobox matches with datagridview particular cell then it should come at first.

How to achieve the same in C#.net forms app ?

asked Jul 23, 2016 in Computer Science - IT by kevin (337 points) | 46 views

1 Answer

+1 vote
Best answer

Below im searching for productname which is available in datagridview column cell 2 , I achieved the result with following code :

             

String searchValue = cmbProductName.Text; int rowIndex = -1;          

foreach (DataGridViewRow row in dgvBarcodePrinting.Rows)

{

if (row.Cells[2].Value.ToString().Equals(searchValue))

{

rowIndex = row.Index;
break;

}

}

dgvBarcodePrinting.Rows[rowIndex].Selected = true;


dgvBarcodePrinting.FirstDisplayedScrollingRowIndex = dgvBarcodePrinting.SelectedRows[0].Index;


answered Jul 23, 2016 by kevin (337 points)
edited Jul 23, 2016 by slow_learner