c# - searching for mulitple columns in a dataGridView -


i have code searching specific column name or column number in datagridview :

        string str = kartsearchtxt.text;         string value = "";         (int = 0; < datagridview1.rows.count; i++)         {             value = datagridview1.rows[i].cells[3].value.tostring();                 if (value.contains(str) == false)                 {                     datagridview1.rows.removeat(i);                     i--;                 }           }     } 

i've tried diffrent solutions having "2 loops " searching through columns aswell , didnt work .

how can search through multiple columns ? in advance

use loop this

for (int = datagridview1.rows.count - 1; >= 0; i--) {     foreach (datagridviewcolumn column in datagridview1.columns)     {         if (!column.visible || column.displayindex < 0)             continue;         value = datagridview1.rows[i].cells[column.displayindex].value.tostring();         if (value.contains(str) == false)         {             datagridview1.rows.removeat(i);         }     } } 

because when remove row(s) grid, datagridview1.rows takes new value


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -