c# - Selecting to View only certain rows in a DataGridView -


i have datagridview of set of data, , want choose 'see' rows on parameters form, shrinks list make choice easier..

i.e.    combobox has 2 choices -> "aaa" , "bbb" =====  column1 | column 2 aaa     | 123 aaa     | 234 bbb     | 345 bbb     | 456 aaa     | 567 bbb     | 678 

after choosing combobox "aaa", should results

column1 | column 2 aaa     | 123 aaa     | 234 aaa     | 567 

this should allow me click row bring info row seperate form..

but original data has remain same.. don;t want change it, view differently..

if using linq datasource filter based on if combobox has selection.

var result = in mydatacontext select i.col1, i.col2  if (! string.isnullorempty(cbcombobox1.text)) {    result = in result i.col1 == cbcombobox1.text             select i; } 

if not using linq datasource use linq apply filter databound datagridview using in indexchanged event. need write remove filter again when want show data.

if (! string.isnullorempty(cbcombobox1.text)) {     var result = datagridviewrow row in dgvdata.rows                  row.cells["column1"].value string != cbcombobox1.text                  select row.index;      foreach (var in result)     {         dgvdata.rows[i].visible = false;     } } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -