logo       

Re: Textbox on non-active tabcontrol page: msg#00332

windows.devel.dotnet.winforms

Subject: Re: Textbox on non-active tabcontrol page

I was curious so I took a peak at the link. This looks to be some kind of
Credit Union website??



-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps
and controls [mailto:DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx]On Behalf Of
Price, Derek
Sent: Wednesday, February 25, 2004 7:51 AM
To: DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx
Subject: Re: [DOTNET-WINFORMS] Textbox on non-active tabcontrol page


Check out the latest source code of genghis [1] on the gotdotnet groups.
It now contains a component that can validate all your controls across
tab pages. It's an extended provider control similar to an
ErrorProvider, etc.

[1] www.genghis.com

-----Original Message-----
From: Zecharya, Bar (FIRM) [mailto:Bar.Zecharya@xxxxxxx]
Sent: Tuesday, February 24, 2004 6:47 PM
To: DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx
Subject: Re: [DOTNET-WINFORMS] Textbox on non-active tabcontrol page

Thanks for all of your interest!

Just to clarify - the form contains one tabcontrol, and each tab
displays certain fields from a single dataset record. The data is bound
to an existing record and once the form is loaded the user may make
changes and click the "Save" button, which runs the method I'm writing.
It could happen that most of the textboxes are filled in, but there is
the chance that the user overlooked a few of the required ones.
Therefore: the tabcontrol is enabled and instantiated, but (of course)
only one of the tabpages can be dispayed at a given time, leaving the
others "inactive." For some reason, all textboxes on the "inactive"
tabpages return true for (tb.Text==""), even if they really do have text
in them.

The idea of checking the dataset may be a good alternate solution, but I
was hoping to be able to access the textboxes themselves, so I could
bring the focus directly to the first blank textbox, even adding an
ErrorProvider message. Otherwise displaying a messagebox explaining
exactly which textbox needs to be filled in on which tabpage could get
out of control.

The only difference between the (workaround) code I posted and the
problem code is that the workaround code contains the call
tabControl1.SelectedTab = page; "Activating" the tabpage before checking
it's controls resolves the
(tb.Text=="") resolves the problem, but at the expense of annoying the
user (and the programmer) with seeing the tabs change rapidly by
themselves when the method is run.


-----Original Message-----
From: Greg Robinson
To: DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx
Sent: 2/24/04 9:30 PM
Subject: Re: [DOTNET-WINFORMS] Textbox on non-active tabcontrol page

I think I am missing something basic here. Why would an inactive, not
enabled, not instantiated control have text? It should not have text
until databinding pushes data to the control, correct?

Again, why not look at the datasource for the bound control?

-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps
and controls [mailto:DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx]On Behalf Of
Hallquist, Rob
Sent: Tuesday, February 24, 2004 3:23 PM
To: DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx
Subject: Re: [DOTNET-WINFORMS] Textbox on non-active tabcontrol page


Sorry if I didn't read the question correctly. I tried the code inside
a button control and it worked fine. I tried it with 3 tab pages and
all of the TextBox controls were empty. The message was displayed for
any non-active tab page. Then I tried it with all of the TextBox
controls having data and then with just some having data. Any
non-active tab page did not display the message. In other words the
if(c.Text=="")
is working fine for me. Could you maybe give me a little more data?

Where is the code that checks for the Text property?

I see the code at the bottom, but that looks like your workaround code.

-----Original Message-----
From: Zecharya, Bar (FIRM)
To: DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx
Sent: 2/24/2004 11:53 AM
Subject: Re: [DOTNET-WINFORMS] Textbox on non-active tabcontrol page

Rob,

Thanks for the advice, but unfortunately that's exactly my problem: the
code

if (c.Text=="")

erroneously returns true when the tabpage it's on isn't the visible page
of the tabcontrol!

Thanks for any advice, suggestions or explanations, Bar


-----Original Message-----
From: Hallquist, Rob
To: Zecharya, Bar (FIRM); 'DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx '
Sent: 2/24/04 6:32 PM
Subject: RE: [DOTNET-WINFORMS] Textbox on non-active tabcontrol page

Why not try something like this:

foreach(TabPage tp in tabControl1.TabPages) {
foreach(Control c in tp.Controls)
{
if(c is TextBox)
if(c.Text == "")
MessageBox.Show("I'm Empty!");
}
}

-----Original Message-----
From: Zecharya, Bar (FIRM)
To: DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx
Sent: 2/24/2004 8:39 AM
Subject: [DOTNET-WINFORMS] Textbox on non-active tabcontrol page

Dear All,

I'm trying to do is check if any of a number of TextBoxes in various
pages of a TabControl are blank.

However, if the TabPage is not the active one I get String.Empty for the
Text property even when there _is_ text inside the TextBox. As a
workaround, I can call SelectedTab() on the TabControl to scroll through
the TabPages, but then the rapid tab-changing is visible to the user! I
tried making the TabControl invisible before the operation and visible
again afterwards to avoid this effect, but then the String.Empty problem
(obviously) reappears!

I'd like to know:
1) How to get the Text property of a TextBox on a non-active TabPage
2) For future purposes, how I can suspend the drawing of a page (while I
do something bizarre like scrolling though all the tabs on a tabControl)

Thanks,
Bar


private bool IsMissingRequired() {
// list of pages and textboxes to check
Hashtable htRequired = new Hashtable();
htRequired[tabPage1] = new TextBox[] {tb1, tb2};
htRequired[tabPage2] = new TextBox[] {tb3, tb4};


foreach (TabPage page in htRequired.Keys) {
tabControl1.SelectedTab = page;
foreach (TextBox tb in (TextBox[])htRequired[page]) {
if (tb.Text.Equals(string.Empty))
return true;
}
}
return false;
}



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise