KK_Zanok
Member
How to create form controls dynamically using code?
Plz give some sample codes.I have tried with the following code but I couldn't get output.
Imports System.Windows.Forms.GroupBox
Imports System.Windows.Forms.CheckBox
Private Sub DrugNameCheckedListbox_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles DrugNameCLib.ItemCheck
Dim GB1 As New GroupBox
Dim CB1 As New CheckBox
Dim CB2 As New CheckBox
Dim CB3 As New CheckBox
GB1.Name = "DrugNameGB1"
GB1.Text = "DrugTime"
CB1.Name = "MornCb"
CB1.Text = "Morning"
CB2.Name = "NoonCb"
CB2.Text = "AfterNoon"
CB3.Name = "NightCb"
CB3.Text = "Night"
GB1.GetContainerControl()
GB1.Controls.Add(CB1)
GB1.Controls.Add(CB2)
GB1.Controls.Add(CB3)
GB1.Visible = True
CB1.Visible = True
CB2.Visible = True
CB3.Visible = True
GB1.BringToFront()
GB1.Show()
End Sub
Plz give some sample codes.I have tried with the following code but I couldn't get output.
Imports System.Windows.Forms.GroupBox
Imports System.Windows.Forms.CheckBox
Private Sub DrugNameCheckedListbox_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles DrugNameCLib.ItemCheck
Dim GB1 As New GroupBox
Dim CB1 As New CheckBox
Dim CB2 As New CheckBox
Dim CB3 As New CheckBox
GB1.Name = "DrugNameGB1"
GB1.Text = "DrugTime"
CB1.Name = "MornCb"
CB1.Text = "Morning"
CB2.Name = "NoonCb"
CB2.Text = "AfterNoon"
CB3.Name = "NightCb"
CB3.Text = "Night"
GB1.GetContainerControl()
GB1.Controls.Add(CB1)
GB1.Controls.Add(CB2)
GB1.Controls.Add(CB3)
GB1.Visible = True
CB1.Visible = True
CB2.Visible = True
CB3.Visible = True
GB1.BringToFront()
GB1.Show()
End Sub