commands don't work???
-
Hi, My project has several tab pages. When tabCoS is clicked on (which contains a datatable/datagrid), if a row was previously selected, I like to select it again.
private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e) { if (this.tabControl1.SelectedTab == tabCoS) { if (rowState == "unselect"){this.dg.Select(row);} } }
This doesn't work. Although when I throw a messagebox in beforethis.dg.Select(row);
, after I hit OK, it works fine and the row is selected. This type of thing has happened before (commands don't work unless I put a messagebox in and click ok). Any idea why??? :confused: Thanks! Mel -
Hi, My project has several tab pages. When tabCoS is clicked on (which contains a datatable/datagrid), if a row was previously selected, I like to select it again.
private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e) { if (this.tabControl1.SelectedTab == tabCoS) { if (rowState == "unselect"){this.dg.Select(row);} } }
This doesn't work. Although when I throw a messagebox in beforethis.dg.Select(row);
, after I hit OK, it works fine and the row is selected. This type of thing has happened before (commands don't work unless I put a messagebox in and click ok). Any idea why??? :confused: Thanks! MelAre you sure your datagrid shows selection when it doesn't have focus? It may be that the tab control maintains focus when you switch between tabs. The return from MessageBox may be handled in a different way (i.e. set focus to first tab stop). Try replacing
{this.dg.Select(row);}
With{this.dg.Select(row);this.dg.Focus();}