C # DataGridView Search

Source: Internet
Author: User

    Private voidButton3_Click (Objectsender, EventArgs e) {                  introw = DataGridView1.Rows.Count;//get total number of rows                intcell=datagridview1.rows[1]. Cells.count;//get total number of columns                stringStrtxt = Txtfind.text;//get the input string and pay the value to the variableRegex r =NewRegex (Strtxt);//defining a Regex object instance                 for(inti =0; i < row; i++)//get the total number of rows and loop within                {                       for(intj =0; J < Cell; J + +)//get the total number of columns and loop within{Match m= R.match (Datagridview1.rows.cells[j]. Value.tostring ());//fuzzy Matching in a string                        if(m.success) {//compares the values in the Texbox with the values in the DataGridView (the sentence above)Datagridview1.currentcell = Datagridview1[j,i];//navigate to the same cell                            if(MessageBox.Show ("do you want to continue searching? ","", messageboxbuttons.okcancel) = =dialogresult.cancel) {//if Cancel is selected, it returns, and if OK is selected, the match will continue to be found.                                 return;//return                            }                          }                      }                  }              }   
    

C # DataGridView Search

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.