471,071 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How can I get child control in GroupBox ??

Dear All:

I have a GroupBox1 in my form, and I add a TextBox1 to GroupBox1.

I want to set some string to TextBox1,how can I do ??

my program:
Dim tt as TextBox
tt=me.controls.item("TextBox1") <--------- Cannot get this
object,it only can get GroupBox1
tt.text="Hello"

--
Best Regards
Sep 5 '07 #1
2 11908
I assume you are adding the textbox dynamically (in code) rather than in the
designer. [If the textbox is added in the designer, you would access the
textbox directly: Me.Textbox1]

For a set of controls added dynamically to a container control, such as the
GroupBox...you could do this...

Dim G As New GroupBox()
Dim t As New TextBox()
Dim tt As TextBox
t.Name = "t"
G.Controls.Add(t)
(add code to for size and location)
Dim i
For i = 0 To G.Controls.Count - 1
If G.Controls(i).Name = "t" Then
tt = DirectCast(G.Controls(i), TextBox)
End If
Next

Sep 5 '07 #2
On Sep 5, 2:54 am, Charlie <cfarrier at charlesfarriersoftware.com>
wrote:
I assume you are adding the textbox dynamically (in code) rather than in the
designer. [If the textbox is added in the designer, you would access the
textbox directly: Me.Textbox1]

For a set of controls added dynamically to a container control, such as the
GroupBox...you could do this...

Dim G As New GroupBox()
Dim t As New TextBox()
Dim tt As TextBox
t.Name = "t"
G.Controls.Add(t)
(add code to for size and location)
Dim i
For i = 0 To G.Controls.Count - 1
If G.Controls(i).Name = "t" Then
tt = DirectCast(G.Controls(i), TextBox)
End If
Next
Also if using VS2005 you have access to the FindControl method you can
use to find child controls.

Thanks,

Seth Rowe

Sep 5 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by h | last post: by
2 posts views Thread by Dave Veeneman | last post: by
3 posts views Thread by BradBrigade | last post: by
reply views Thread by Qwert | last post: by
2 posts views Thread by isacc manit | last post: by
3 posts views Thread by Jon Paal | last post: by
reply views Thread by --== Alain ==-- | last post: by

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.