Legacy, just want to let you know that your answer Posted on 09/11/2003 12:00am After all this time is helping me so very much. Thank you,
Replygd morning hve a question regaring dynamically creating of controls using such as 'Set FM1 = Controls.Add("vb.Frame", "Frame1")' posible to use a dynamic name (string) instead of a fixed name? strObjName = "NewObj" & Counter Form1.Controls.Add("vb.textbox", strObjName, Form1) cannot use above system.
Replyhow to create form dynamically
ReplyHi, I want to create a menu control(support unicode) but i dont know to create it. Please tell me how to create or sourcecode. Thanks.Reply
Originally posted by: Pranav Jariwalla
Well, but how can we add run time buttons in to Frame
Friend, Heres the code to do the same. Sorry for the delay in Replying. ------------------------------------------ Option Explicit Dim WithEvents Cmd1 As CommandButton Dim WithEvents FM1 As Frame Private Sub Form_Load() Set FM1 = Controls.Add("vb.Frame", "Frame1") FM1.Top = 150 FM1.Left = 300 FM1.Width = 3000 FM1.Height = 2000 FM1.Caption = "Dynamic Frame" 'FM1.Name = "Frame1" FM1.Visible = True Me.Show DoEvents Set Cmd1 = Controls.Add("vb.commandbutton", "Cmd1") Cmd1.Width = 2000 Cmd1.Top = Me.Height / 2 - Cmd1.Height / 2 - 100 Cmd1.Left = Me.Width / 2 - Cmd1.Width / 2 - 100 Cmd1.Caption = "Dynamic Button" Set Cmd1.Container = FM1 Cmd1.Visible = True End Sub ' Private Sub Cmd1_click() MsgBox "I have been Created Dynamically at Run-time, with Frame 1 as my container.", , "Dynamic Controls" End Sub ------------------------------------------
ReplyOriginally posted by: Deen Bandhu
How to add event on dynamically created control.
I have tried with this code.
For i = 1 To 2
Set ctlOpt(i) = Form1.Controls.Add("VB.OptionButton", "Opt" & i, ctlFrm(1))
With ctlOpt(i)
If i = 1 Then
.Top = 100
Else
.Top = ctlOpt(i - 1).Top + 500
End If
.Left = 600
.Caption = .Name
.Visible = True
End With
Next
Now I need fire event on each option button. It is possible with one control but not with array control
Originally posted by: Deen Bandhu
But one problem is still there how to dispaly multiple control arryay say text box in limited space of form.
For that i need a scrollable container like in html page to vied n number of control.
Plz Help me
Thanks.
Finally I got the code for dynamic control Arry.
Originally posted by: arun prakash
The code was nice & simple.But I want to know how to write events.I have create an array of textboxes.PLzzzzzzzz help me .Thanks in advance
Please send me your code on thsi address ping_manoj@hotmail.com. Let me see what exaclt are w etalking about.
ReplyThe code was nice & simple.But I want to know how to write events.I have create an array of textboxes.PLzzzzzzzz help me .Thanks in advance
ReplyOriginally posted by: aditul
On a blank form
-create textBox
-rename it to arrayText
-selct the textBox
-copy
-paste
You'll be asked if you want to create a control array 'cause you have another textBox with the same name
-click ok
you have now the array control created.
you can delete the second now.
you'll have one control array with only one control
-fill in this code in Form_Load()
For i = 1 To 10
Load arrayText(i)
arrayText(i).Left = arrayText(0).Left
arrayText(i).Top = arrayText(0).Top + 300 * i
arrayText(i).Text = "array textbox dynamic (" & i & ")"
arrayText(i).Width = 3500
arrayText(i).Height = 285
arrayText(i).Visible = True
MsgBox "textbox dynamic nr " & i, vbOKOnly + vbInformation, "Created???"
Next i
Run it, should work.
Hello Legacy, I just want you to know that your answer to this questions after all this time is still helping people. It is helping me a lot. Thank you very much!
ReplyI needed to add a 'number' of controls, and just couldn't get my head around the syntax. This article worked first time! :)
ReplyOriginally posted by: stewart
This is fine, but does anyone know how to destroy the controls (equivalent to FreeAndNil in Delphi) - not just setting their .visible property to False?
Will the use of dynamically created and removed controls work to avoid the 255 control limit for a form?Reply
Controls.Remove ("cmd1")
Reply