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
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.