Solved

Disable custom controls event

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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