Solved

Disable custom controls event

Posted on 2009-05-04
1
179 Views
Last Modified: 2012-05-06
I have a custom control that contains a datagrid. On some forms I want the user to be able to double click a cell, but sometimes I dont want that even enabled. Is there a way to disable this? I was thinking maybe pass in a flag telling it whether to do the events code or not. What is the best way to do this?
Thanks!
0
Comment
Question by:bertino12
1 Comment
 
LVL 15

Accepted Solution

by:
oobayly earned 500 total points
ID: 24296550
That's probably the easiest way to do it. Another method would be to use AddHandler & RemoveHandler so that the event is never handled.
  Private m_HandleClick As Boolean

  

  Public Property HandleClick() As Boolean

    Get

      Return m_HandleClick

    End Get

    Set(ByVal value As Boolean)

      If (m_HandleClick = value) Then Return

      

      m_HandleClick = value

      If (m_HandleClick) Then

        AddHandler grid.Click, AddressOf grid_Click

      Else

        RemoveHandler grid.Click, AddressOf grid_Click

      End If
 

    End Set

  End Property

Open in new window

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now