471,088 Members | 1,267 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Accessing dynamically created controls

Hi all,
I am trying to create a VB smart device application.
I create few buttons dynamically on form_load...

something like this:
Dim WithEvents BtnOperate As New OpenNETCF.Windows.Forms.Button2
Me.BtnOperate.Location = New System.Drawing.Point(20, 20)
Me.BtnOperate.Size = New System.Drawing.Size(150, 150)
Me.BtnOperate.TabIndex = 0
Me.BtnOperate.BackgroundImage = b

then i have a datareceived event in a module, where i receive a command to set focus on one of the buttons (for example left of the one that currently has a button), i tried this trough the property
like this:
Public Property CtrlFocus() As Integer
Dim i As Integer = Me.Controls.Count
Dim ctrl As Control
For Each ctrl In Me.Controls
If ctrl.Focused Then
Return ctrl.TabIndex
End If
End Get
Set(ByVal value As Integer)
Dim ctrl As Control
For Each ctrl In Me.Controls
If ctrl.TabIndex = value Then
End If
End Set
End Property

with this commands that are in my module...:
dim fm as new frm_main
index = fm.CtrlFocus
frm_main.ctrlfocus = index +1

but when i try this there is no controls in me.controls in property CtrlFocus!
How could I access dynamically created controls from another thread...or get a list of them...

Hope this is clear whats the problem.
May 8 '07 #1
1 1679
i think you can solve prob

i have used the follwing code in page load event to dynamically generate 5 text boxs.

Dim i As Integer
For i = 1 To 5
Dim txtBox As New TextBox
txtBox.ID = String.Format("txtBox{0}", i)

now i want to display those entered text in same page when i click on button..
so please help me out... its urgent
May 8 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Jonathan Williams | last post: by
1 post views Thread by drakuu | 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.