PC Review


Reply
Thread Tools Rate Thread

Controls in groupboxes

 
 
Steven Smith
Guest
Posts: n/a
 
      12th Oct 2003
Hi guys I'm using object variables to address several
controls on a form like so...

Private Sub cmdReset_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) _
Handles cmdReset.Click

Dim intX As Integer
Dim objTextBox As TextBox
For intX = 0 To Controls.Count - 1
If TypeOf Controls.Item(intX) Is TextBox Then

objTextBox = Controls.Item(intX)
objTextBox.Text = ""
End If
Next intX

This works fine for any textboxes on my form outside of
groupboxes, The problem is I must also address the
textboxes within the groupboxes.

How do I reference these controls, surely it must be
possible to access controls within groupboxes I'm sure
I'm missing something simple.

Can anyone point me in the right direction... ?

Thanks in advance
Regards Steve...
 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      12th Oct 2003
* "Steven Smith" <(E-Mail Removed)> scripsit:
> Hi guys I'm using object variables to address several
> controls on a form like so...
>
> Private Sub cmdReset_Click(ByVal sender As System.Object,
> ByVal e As System.EventArgs) _
> Handles cmdReset.Click
>
> Dim intX As Integer
> Dim objTextBox As TextBox
> For intX = 0 To Controls.Count - 1
> If TypeOf Controls.Item(intX) Is TextBox Then
>
> objTextBox = Controls.Item(intX)
> objTextBox.Text = ""
> End If
> Next intX
>
> This works fine for any textboxes on my form outside of
> groupboxes, The problem is I must also address the
> textboxes within the groupboxes.
>
> How do I reference these controls, surely it must be
> possible to access controls within groupboxes I'm sure
> I'm missing something simple.


<http://www.mvps.org/dotnet/dotnet/samples/controls/downloads/EnumerateControls.zip>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      12th Oct 2003
Hi Steven,
I did not check if the methode you use works, it is unusual but why not.
> Private Sub cmdReset_Click(ByVal sender As System.Object,
> ByVal e As System.EventArgs) _
> Handles cmdReset.Click
> Dim intX As Integer
> Dim objTextBox As TextBox
> For intX = 0 To Controls.Count - 1


I think here it has to be
For intX = 0 to Groupbox.Controls.Count - 1

> If TypeOf Controls.Item(intX) Is TextBox Then
>
> objTextBox = Controls.Item(intX)


objTextBox=Groupbox.Item(intX)

> objTextBox.Text = ""
> End If
> Next intX
>

Do I don't know if it works but I think so.

Normal is typed, maybe type errors
\\\
dim ctrl as control
For each ctrl in groupbox.controls
if typeof ctrl is textbox then
ctrtxt = directcast(ctrl, textbox)
ctrtext=""
end if
next
///
Cor







Cor


 
Reply With Quote
 
Steven Smith
Guest
Posts: n/a
 
      13th Oct 2003
This more or less worked fine, cheers for the help cor,
got me out of a tricky spot

>dim ctrl as control
>For each ctrl in groupbox.controls
> if typeof ctrl is textbox then
> ctrtxt = directcast(ctrl, textbox)
> ctrtext=""
> end if
>next
>
>
>
>
>
>
>
>Cor
>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GroupBoxes too big Joe Microsoft C# .NET 3 13th Jun 2008 08:33 AM
Nested GroupBoxes jagrat@gmail.com Microsoft Dot NET Framework 5 11th Feb 2005 12:54 PM
Bug? .NET 1.1 SP1 + Nested Groupboxes = Suck Lee Gent Microsoft Dot NET Framework Forms 4 24th Sep 2004 07:05 PM
Nested Groupboxes Joe Griffith Microsoft VB .NET 3 21st Sep 2004 08:52 PM
EnableVisualStyles and GroupBoxes =?Utf-8?B?RGF2ZQ==?= Microsoft Dot NET 4 5th Jun 2004 05:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:07 AM.