V
Vanessa
Hi all!
I have a tab control and in one tab page I have 8 textbox and 2 grids. The
textbox are all numerics and have the following behavior: when I digit the
2nd textbox then the 3rd textbox is updated with the 2nd more the difference
between the 1st and 2nd, and so on.
Example 1:
TB 1: 10, TB 2: 20 -> TB 3 will be updated with 30
Example 2:
TB 1: 15, TB 2: 30, TB 3: 45 -> TB 4 will be updated with 60
When I say "will be updated", it is updated on textbox_Validating() event.
If I'd like to digit just 4 textbox, I left the 5th with zero (or blank) and
it works fine. If I am on the 4th textbox and then click on one of the grids,
it is ok too. But if the focus is on the 4th textbox (with some value greater
than 0), and I click on another page of the tab control, it is not working.
The problem is that on textbox_Validating() event, where I have the following
test:
private void textbox_Validating(object sender, CancelEventArgs e)
{
TextBox tb = sender as TextBox;
if (tb.Focused == true)
{
UpdateNextTextbox();
}
}
In UpdateNextTextbox() method I update the next number according I explained
above and call Focus() event of the next textbox. When I click on the grid,
the "if (tb.Focused == true)" is false and the next textbox will not be
updated, and it is ok. The problem is that if I click on another tab page,
this "if" is true, i.e., the focus is still on the textbox, and the next
textbox is updated, what is wrong.
I already tried Selecting(), Deselecting(), SelectedIndexChanged() and other
events of tab control, but all them are called after textbox_Validating(). So
what I want is to know if it is changing tab page before
textbox_Validating(). Any idea?
Thank you!
Vanessa
I have a tab control and in one tab page I have 8 textbox and 2 grids. The
textbox are all numerics and have the following behavior: when I digit the
2nd textbox then the 3rd textbox is updated with the 2nd more the difference
between the 1st and 2nd, and so on.
Example 1:
TB 1: 10, TB 2: 20 -> TB 3 will be updated with 30
Example 2:
TB 1: 15, TB 2: 30, TB 3: 45 -> TB 4 will be updated with 60
When I say "will be updated", it is updated on textbox_Validating() event.
If I'd like to digit just 4 textbox, I left the 5th with zero (or blank) and
it works fine. If I am on the 4th textbox and then click on one of the grids,
it is ok too. But if the focus is on the 4th textbox (with some value greater
than 0), and I click on another page of the tab control, it is not working.
The problem is that on textbox_Validating() event, where I have the following
test:
private void textbox_Validating(object sender, CancelEventArgs e)
{
TextBox tb = sender as TextBox;
if (tb.Focused == true)
{
UpdateNextTextbox();
}
}
In UpdateNextTextbox() method I update the next number according I explained
above and call Focus() event of the next textbox. When I click on the grid,
the "if (tb.Focused == true)" is false and the next textbox will not be
updated, and it is ok. The problem is that if I click on another tab page,
this "if" is true, i.e., the focus is still on the textbox, and the next
textbox is updated, what is wrong.
I already tried Selecting(), Deselecting(), SelectedIndexChanged() and other
events of tab control, but all them are called after textbox_Validating(). So
what I want is to know if it is changing tab page before
textbox_Validating(). Any idea?
Thank you!
Vanessa