Searching Multiple rows in datagridview through button click

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinutha b
    New Member
    • Jan 2012
    • 1

    #1

    Searching Multiple rows in datagridview through button click

    private void button1_Click(o bject sender, EventArgs e)
    {
    //
    DataGridView dgview = new DataGridView();
    //dataGridView1.R owCount=0;
    try
    {
    for (int row = 0; row < dataGridView1.R owCount - 1; row++)
    {

    // dataGridView1.M ultiSelect = false;

    if (dataGridView1. Rows[row].Cells["Model"].Value.ToString ().Substring(0, textBox1.Text.L ength) == textBox1.Text)
    {
    dataGridView1.R ows[row].Selected = true;
    dataGridView1.R ows[row].Cells["column1"].Value = true;
    // MessageBox.Show ("data has been selected");
    }
    else
    {
    MessageBox.Show ("data not found");
    }
    }
    }
    catch (Exception Error)
    {
    //MessageBox.Show ("data not selected");
    MessageBox.Show (Error.ToString ());
    }


    }
    i have above code ........... when i perform it shows exception has "index and length must refer to the same location within the string" i'm not getting what to do .... fresher to this application ........pls help me
Working...