472,961 Members | 2,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

How to detect when a tab page is being selected?

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
Jul 15 '08 #1
2 7475
Hi Vanessa,

Set the CausesValidation property of your TabControl to false. You don't
have to handle its events either.

Best Regards,
Stanimir Stoyanov
www.stoyanoff.info

"Vanessa" <Va*****@discussions.microsoft.comwrote in message
news:F7**********************************@microsof t.com...
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
Jul 15 '08 #2
Hi Stanimir,

It worked like I needed!

Thank you very much!
Vanessa
"Stanimir Stoyanov" wrote:
Hi Vanessa,

Set the CausesValidation property of your TabControl to false. You don't
have to handle its events either.

Best Regards,
Stanimir Stoyanov
www.stoyanoff.info

"Vanessa" <Va*****@discussions.microsoft.comwrote in message
news:F7**********************************@microsof t.com...
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
Jul 15 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

157
by: Dennis | last post by:
Is there some way --using, say, DOM or javascript-- to detect the current pixel width and/or height of a relatively sized table or of one of its columns or rows. I'm going to be writing javascript...
1
by: onewebclick | last post by:
Is there a way to detect a browser cache is full using javascript or HTML thorugh a web page and inform the user to clear the cache to improve performance of the website. It looks like google's...
17
by: Paul | last post by:
HI! I get an error with this code. <SCRIPT language="JavaScript"> If (ifp==""){ ifp="default.htm"} //--></SCRIPT> Basicly I want my iframe to have a default page if the user enters in...
2
by: Bob Hynes | last post by:
Hi All, When a user(s) click on the 'Apply Filter' toolbar button I want to run some code before the 'apply filter' kicks off. That code is to check to be sure that the user has selected a value...
6
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
3
by: Sam | last post by:
Hi, I'd like to get the selected node when the user select a node in my treeview. I know how to get the selected node, what I don't know is how to detect that the user has selected a new node. ...
2
by: DavidPr | last post by:
I'm creating (trying to create) a picture gallery for my website. The script is not working. I've been working on it now for about 80 hours with no success. My php skills aren't very good. This...
4
by: nrocha | last post by:
Hello, I've been trying to detect when a user closes a page or navigates away from it. This is part of a solution for locking pages (that is, if a user enters a page, no one else can enter it...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.