Results 1 to 2 of 2

Thread: how to get the row index value in datagridview

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    65

    how to get the row index value in datagridview

    hi i have a form name frmDataEntry with textboxCustID and textboxCustName and lookup form name frmCustAssist with texboxFilter, button Filter and datagridview then when i double click textboxCustID then frmCustAssist will show i have to look if customer already exist or not then if already exist i hav to get the value of row index ..then the custID and custName of that value selected will be fill in the formDataEntry in textboxCustID and textboxCustName how do code that that plz help

    my code is here..



    Code:
     in a frmCustAssist
    
     private void button1_Click(object sender, EventArgs e)
            {
                bindingSource1.Filter = "LASTNAME like '%" + textBox1.Text + "%'";
                bindingSource1.Sort = "LASTNAME";
               selected row value .. somwthing like that
    
            }
    in a frmDataEntry

    selected value custID =textboxCustID
    selected value custname = textboxCustName

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: how to get the row index value in datagridview

    When you're working with bound data you should almost exclusively work with the BindingSource. That's what it's for. In this case the DataGridView is irrelevant.

    Call the Find method of the BindingSource and it will return the index of the matching row if there is one. If there is, you index the BindingSource to get that row and update the appropriate fields. If there isn't, you call the AddNew method of the BindingSource to create a new row and set the appropriate fields.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width