0

Morning,

I am trying to add a click event for the controls that i add into my Panel dynamically. The control i add is a custom class that i have created called 'Slide'.

Here is the code where i build the Slide class that will be added to the panel:

        Dim thisControl As New Slide()
        With thisControl
            .Dock = System.Windows.Forms.DockStyle.Left
            .Thumbnail.Image = ThisSlide
            .Thumbnail.BackColor = Color.Transparent

            .Caption.Text = "Slide" & radSlides.SelectedIndex
            .Ordinal = pnlScheduledSlides.Controls.Count.ToString
            .Duration = Conversion.Int(20)
            .Content = pContent
        End With

Then I add 'thisControl' to the panel:

pnlScheduledSlides.Controls.Add(thisControl)

I am wanted to be able to click on a Slide inside the panel so that i can add some functionality to be able to add/remove the slide.

Ben Clarke
  • 1,051
  • 4
  • 21
  • 47

1 Answers1

0

You need a dinamic event handler

Addhandler thisControl.Click, AddressOf  your_dinamic_click

Where your_dinamic_click is something like this:

Private sub your_dinamic_click(sender As Object, e As EventArgs)

I'm supposing that your Slide control raises a "click" event

Morcilla de Arroz
  • 2,104
  • 22
  • 29