Solved

Disable custom controls event

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 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