• Top Members
    Reps
    Posts
  • 834 Replies
    2585 Replies
  • 716 Replies
    2026 Replies
  • 331 Replies
    1928 Replies

How to remove click event handlers from a flowlayoutpanel

Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
User avatar
Dummy1912
VIP - Donator
Posts: 1983

How to remove click event handlers from a flowlayoutpanel

Sat May 04, 2019 10:18 pm

Hello,

I have no idea how to do that...

i just added the click event when making flowlayoutpanels
now i need to check if there are 3 labels in each flowlayoutpanels
if so i need to remove the click event from that flowlayoutpanel

can anyone helpme please

Thanks

User avatar
CodenStuff
Site Admin
Posts: 4381

Re: How to remove click event handlers from a flowlayoutpanel

Thu May 09, 2019 3:36 pm

Is this a control you've made yourself?

In any case you should just be able to remove the handler thus so:

Code: Select all

RemoveHandler FlowLayoutPanelName.Click, AddressOf FlowLayoutPanelName_Click
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.

User avatar
Dummy1912
VIP - Donator
Posts: 1983

Re: How to remove click event handlers from a flowlayoutpanel

Thu May 09, 2019 4:30 pm

Hello,

no its the default control
how can i count if there are just 3 labels in the flowlayoutpanel

my code

Code: Select all

    Private ListflDay As New List(Of FlowLayoutPanel)

Code: Select all

 For i As Integer = 1 To totalDaysMonth
            Dim lbl As New mLabel 
            lbl.Name = $"lblDay{i}"
            Dim day As Integer = i

            lbl.AutoSize = False
            lbl.TextAlign = ContentAlignment.MiddleRight
            lbl.Size = New Size(125, 22)
            lbl.Text = i

            ListflDay((i - 1) + (startdayatFlNumber - 1)).Tag = i
            ListflDay((i - 1) + (startdayatFlNumber - 1)).Controls.Add(lbl)
            Next

Code: Select all

        For Each c As Control In ListflDay
            'If TypeOf c Is FlowLayoutPanel Then
            If TypeOf c Is mLabel Then
                count += 1
                c.Refresh()
            End If
            'End If
        Next
        

Code: Select all

        For Each link As Control In FlowLayoutPanel
            If TypeOf link Is FlowLayoutPanel Then
                If TypeOf link Is mLabel Then
                    count += 1
                End If
            End If
        Next
        MsgBox(count)
        If count > 2 Then
            For Each fl As FlowLayoutPanel In ListflDay
                RemoveClickEvent(fl)
            Next
        End If
but nothing happens

Thanks

User avatar
CodenStuff
Site Admin
Posts: 4381

Re: How to remove click event handlers from a flowlayoutpanel

Thu May 09, 2019 5:27 pm

I think this code:

Code: Select all

For Each link As Control In FlowLayoutPanel
            If TypeOf link Is FlowLayoutPanel Then
                If TypeOf link Is mLabel Then
                    count += 1
                End If
            End If
        Next
        MsgBox(count)
        If count > 2 Then
            For Each fl As FlowLayoutPanel In ListflDay
                RemoveClickEvent(fl)
            Next
        End If
Should be:

Code: Select all

For Each link As Control In FlowLayoutPanel
           	
                If TypeOf link Is mLabel Then
                    count += 1
                End If
            
        Next
        MsgBox(count)
        If count > 2 Then
            For Each fl As FlowLayoutPanel In ListflDay
                RemoveClickEvent(fl)
            Next
        End If
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.


Post Reply

Return to “Coding Help & Support”