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.Controls.Add(Me.BtnOperate)
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
Get
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
Next
End Get
Set(ByVal value As Integer)
Dim ctrl As Control
For Each ctrl In Me.Controls
If ctrl.TabIndex = value Then
ctrl.Focus()
End If
Next
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.
Thanks
Grega
|