I have a tab control and 3 tabpages in it. ( C#)
if i am in tab 2, and edit a text box value and then click tab 3, i need to validate what was enetered in the text box. if correct i should allow to to switch to tab 3 else should remain in tab 2 it self how do i achieve this?
iam curently handling the "leave" event of the tabpage2, i validate the text box value there and if found invalid i set as tabcontrol.Selectedtab = tabpage2; this does the validation but switches to new tab! how could i restrict the navigation.
I am a novice to C#, so may be i am handling a wrong event!
Here is the relevant code:
private void tabpage2_Leave(object sender, EventArgs e)
{
if (Validatetabpage2() == -1)
{
this.tabcontrol.SelectedTab =this.tabpage2;
}
}