i have created a dynamic contextmenustrip and added dynamic item to it. How do i assign dynamic controls to it. For example
i have added dynamic item as such "A1",:"A2","A3"... so on
each value has controls to the flow-layout panel if i click A1 then the button should be moved from parent panel to the "A1" panel. if i click "A2" it has to go to panel "A2". The no of flow panels are dynamic. Is this question clear? Is it possible to assign controls dynamically as well? Here is the code i did so far
Here i created dynamic menu and adding item
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim pt As New ContextMenuStrip
Dim pt1 As New ContextMenuStrip
Me.ContextMenuStrip = pt
pt.Name = "Cont1"
For Each c As Control In FlowLayoutPanel1.Controls
If TypeOf c Is FlowLayoutPanel Then
array.Add(c.Name)
AddHandler pt.Click, AddressOf contest
End If
Next
Dim data As String
For Each Data In array
pt.Items.Add(data)
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Here i want the controls where am having problem
Private Sub contest(sender As Object, e As EventArgs)
Dim pt As New ContextMenuStrip
pt = CType(sender, ContextMenuStrip)
MsgBox(pt.Name)
End Sub