Hi,
I have developed a screen where there is a datagridview at the top and a set of tabs at the bottom of the page, which is the details of the selected row in the Datagridview. I set the datasource on the datagridview to my Collection object, and databound each TextBox to a Specific field from the objects. My collection object inherit from System.Collections.Generic.List<T>
Emails oEmails = new Emails();
dgEmails.DataSource = oEmails;
tbEmailAddress.DataBindings.Add(new System.Windows.Forms.Binding("Text", oEmails, "EmailAddress", true));
This methodology works when I use the mouse to click around the datagridview, however when I choose to create a new Email:
dgEmails.DataSource = null;
Email oEmail = oEmails.CreateEmail( "Ken", "Ken@Outlook.com");
dgEmails.DataSource = oEmails;
foreach ( DataGridViewRow row in dgEmails.Rows)
{
if (row.DataBoundItem == oEmail)
{
row.Selected = true;
}
else
{
row.Selected = false;
}
}
The correct row is now selected, but the Textbox tbEmailAddress still shows the value from the previous row selected. But if I click on the currently selected row, which is the new row it updates the textbox. How do I update the Textbox value automatically?
Thanks,
Ken