473,378 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 7492
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.