Solved

Disable custom controls event

Posted on 2009-05-04
1
180 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Encryption Decryption in Oracle 12 108
Red error squiggly on vb.net 7 27
How to remove double quotes from a string in VB.Net 5 38
Help with LINQ and XML 10 28
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

863 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

21 Experts available now in Live!

Get 1:1 Help Now