I believe you have created a UserControl and added a ToolStrip control
on it?
If yes, did you try adding this UserControl to a form?

Because, it seems to work fine...

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        Dim tb As New ToolStripButtonMenu
        Dim aParam As New ArrayList()

        aParam.Add("MenuItem1")
        aParam.Add("MenuItem2")
        aParam.Add("MenuItem3")
        aParam.Add("MenuItem4")

        tb.CreateButtonMenu(aParam)

        Me.Controls.Add(tb)
    End Sub

Also, I think the For loop in your user control should be:
 For i = 0 To aParam.Count - 1

Thanks,
Kaarthik

On Dec 21, 11:44 am, Nakkeeran k <[email protected]> wrote:
> Hi
>
>   i had created dynamic tool strip button user control.But the run time
> buttons are not visible.i dont know where i am doing mistake.please help me
> to solve this problem.
>
> This is code
>
> Public Class ToolStripButtonMenu
>
>     Public Sub CreateButtonMenu(ByVal aParam As ArrayList)
> ToolStripInterface.CreateButtonMenu
>         If Not aParam Is Nothing And aParam.Count > 0 Then
>             Me.ToolStripControl.SuspendLayout()
>             Me.SuspendLayout()
>             Dim tb(aParam.Count - 1) As ToolStripButton
>
>             For i = 0 To aParam.Count
>                 tb(i) = New ToolStripButton
>                 tb(i).BackColor = System.Drawing.SystemColors.ActiveCaption
>                 tb(i).AutoSize = True
>                 tb(i).Name = aParam.Item(i).ToString
>                 tb(i).Text = aParam.Item(i).ToString
>                 AddHandler tb(i).Click, AddressOf ToolStripButton_Click
>             Next
>             Me.ToolStripControl.Items.AddRange(tb)
>             Me.ToolStripControl.ResumeLayout(False)
>             Me.ToolStripControl.PerformLayout()
>             Me.ResumeLayout(False)
>             Me.PerformLayout()
>         End If
>
>     End Sub
>     Private Sub ToolStripButton_Click(ByVal sender As System.Object, ByVal e
> As System.EventArgs)
>         MsgBox("From userControl")
>     End Sub
> End Class
>
> Thanks in advance
> Nakkeeran.k

Reply via email to