search - Searching in datagridview using c# -


After loading a table in the DataGrade view, I am generating items from a Cambodia with the Data Grid column header. From the Combobox I am selecting the column and I have a textbox for the search value given by the user. I am using the following code:

  string searchfortext = txtCrudSearch.Text; DgvLoadTable.ClearSelection (); DgvLoadTable.SelectionMode = DataGridViewSelectionMode.FullRowSelect; Try {Foreach (DatagridViewRow line in dgvLoadTable.Rows) {if (row.Cells [cboCrudSearchColumn.SelectedIndex] .Value.ToString (). Equals (SearchForText)) {row.Selected = true; // If I use the break here, the code does not give an exception / but only highlighting one line I want to return all the rows, which matches the // with the search string}}} Catch (Exceptional) {message box. Show (ex.Message); }   

Now, the problems are:

  1. Exception to me is not set for an example of "object reference object" / li>
  2. How can I return to the datagrid instead of just lighting?
  3. Search is case sensitive, how does it work for all types?

    I know this. If someone needs a solution, then the code is as follows:

      Private Zero btnCrudSearch_Click (Object Sender, EventArgs e) {dgvLoadTable.CurrentCell = null; DgvLoadTable.AllowUserToAddRows = Incorrect; DgvLoadTable.ClearSelection (); DgvLoadTable.SelectionMode = DataGridViewSelectionMode.FullRowSelect; DgvLoadTable.ReadOnly = True; {Foreach (DatagridViewRow line in dgvLoadTable.Rows) Try {var cellValue = row.Cells [cboCrudSearchColumn.SelectedIndex]. value; If (cell valley! = Null & amp; amp; cellwhicho.Testring () == txtCrudSearch.Text.ToUpper ()) {row.Selected = true; Line. Visible = true; } And row View = false; }} Catch (Exceptions) {message box. Show (exc.message); }}    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -