c# - Searching DataGrid for matching values -


i have data grid can queried based on combobox choice .

my code (shown below) meant search through datagrid , if finds row matching piece of text meant move datagrids selected index corresponding row.

    (int = 0; <= dashboard_datagrid.columns.count - 1; i++)             {                 if  (dashboard_datagrid.rows[0].tostring().tolower().contains(combobox9.text.tostring().tolower()))                 {                     value = dr.cells[i].value.tostring();                     // return dr.cells[i].rowindex;                     dashboard_datagrid.selectedcells[i].rowindex =  dr.cells[i].rowindex;                  }             } 

however getting following error

           error    7   property or indexer 'system.windows.forms.datagridviewcell.rowindex' cannot assigned -- read 

does know how fix error ? searching online hasn't givin solution

you trying change selectedcell's row index, read-only. if trying change selected row, need set selectedindex datagrid.

dashboard_datagrid.selectedindex = dr.cells[i].rowindex; 

also, try changing selectedcells selectedrows.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -