I have a form 1 with 2 datagrid view controls and tab control with two tabs.
When I click on the datagridview cell I want to load something into two tabs.
First Tab
I want to display the selected datagridview row values in text boxes in first tab…. this was working fine….
Second tab
I want to populate the other datagridview in this tab depending on the selected row value (cell [0] value) in main the datagridview in form
But this is not working.
This is what I have done so far…
private void dgvCorporatedetails_CellClick(object sender, DataGridViewCellEventArgs e)
{
textboxreadonly(false);
btnAdd.Enabled = false;
if (e.RowIndex >= 0)
{
int.TryParse(dgvCorporatedetails.Rows[e.RowIndex].Cells[0].Value.ToString(), out corporateid);
if (corporateid > 0 && tccorporates.SelectedTab == tpDetails)
{
getselectedrecord(corporateid);
}
if (corporateid > 0 && tccorporates.SelectedTab == tpmembers)
{
Getmembersdetails(corporateid);
}
}
}
It does not enter into this condition if (corporateid > 0 && tccorporates.SelectedTab == tpmembers)
even if I click on the datagridview cell and then I select the tab2(tpmembers) datagridview does not load in this tab page (tpmembers)
would any one pls help on this…
Place a breakpoint on that line then. Is corporateid greater than 0? Is the SelectedTab set to tpmembers? If your first
ifstatement runs, indicating that the currently selected tab is tpDetails, then the secondifstatement will not run. Your if statements, as written, are mutually exclusive.The way you’ve got it now, if the user is on tab1 and selects a row in the grid, then only tab1 will show data regarding the selected row. If they want to view the data in tab2, they have to click on your grid again to load data into that tab. How about just loading all the data into both tabs at once, regardless of which one is currently selected?
Just omit the
tccorporates.SelectedTab == tpDetailsandtccorporates.SelectedTab == tpmembersstatements from yourifblocks. When the user clicks on tab2, everything will already be loaded for them.