473,386 Members | 1,708 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,386 software developers and data experts.

Controls in groupboxes

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...
Nov 20 '05 #1
3 2743
Cor
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
Nov 20 '05 #2
* "Steven Smith" <St**********@emailaccount.com> 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>
Nov 20 '05 #3
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
.

Nov 20 '05 #4

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

Similar topics

0
by: Mark Johnson | last post by:
Sometimes Controls that have been added to a GroupBox do not show up. What I am doing : 1) I am not using the designer, but create all the Controls per hand: groupBoxProdukt_01 = new...
6
by: Martin | last post by:
Maybe I'm tired, but I can't figure out a simple way for two controls to share the size of the parent control. e.g when the parent's height becomes NewHeight the first control's new height becomes...
4
by: Dan Baker | last post by:
I have a form with several controls. I would like to paint *over* several controls (mainly GroupBoxes and Labels). But, Everywhere I try to perform painting, I end up "behind" the controls. I need...
2
by: D Hass | last post by:
Radio Buttons are added to my form During the Load event, the quantity determined by User input. They are placed in pairs on groupboxes with code like this: (edited a bit for brevity) Public...
4
by: romy | last post by:
Hi In VB.net I have a set of linkButtons controls in a form , which I want to iterate on them and change their text property. How it's done ? thanks
7
by: Eduardo78 | last post by:
Hello everybody, I heard I could clear (or move spaces) to all controls at ones without having to call each one of them. If someone remembers how to do that, I will apreciate your help. My...
2
by: Kay | last post by:
Hi all, I have a 42 groupboxes in a panel, each groupbox has 3 check boxes in it. The 42 groupboxes are actually in a panel, and the panel is on the second tab page of a tab control... What...
4
by: stacy | last post by:
I would like to create 4 tab pages in a tab control. 1 tab is for properties, 1 is for status and 2 of the tabs will have the same controls on them, for settings. The two settings tab pages will...
7
by: RichG | last post by:
I want to lock all controls except the buttons on a form. I sometimes need the form to call lockForms(Me). public sub lockControls(frm as form) for each ctrl as control in frm if...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.