473,394 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to implement enable/disable for control

Hi!
I'm trying to implement custom button. But I don't want to extend
Button class.
I want to extend Control class.
I want to implement Enable disable functionality.
But unfortunatly when control is in Enable = false state the on click
event is not called but that event is passed to parent object.
How to convince my custom button class not to pass Click events to
parent classes when my class is in Disabled state?

Thanks in advance

Jul 28 '06 #1
2 9117
"ba*******************@gmail.com" wrote:
I'm trying to implement custom button. But I don't want to extend
Button class.
I want to extend Control class.
I want to implement Enable disable functionality.
But unfortunatly when control is in Enable = false state the on click
event is not called but that event is passed to parent object.
How to convince my custom button class not to pass Click events to
parent classes when my class is in Disabled state?
Unfortunately, if the Button is disabled, it will not receive mouse events,
which means events pass on to the button's parent control.

Off the top of my head, I can think of two options, both a little tricky:

1. Create a transparent control and place it over your disabled control.
Then monitor for mouse events in your transparent control. Here's how to
make controls transparent:

http://www.c-sharpcorner.com/Code/20...ntControls.asp

2. Monitor for the mouse clicks in your parent control, then pass them to
your custom button.

--
Timm Martin
Mini-Tools
..NET Components and Windows Software
http://www.mini-tools.com

Jul 28 '06 #2
Hi,

You could inherit from Control and override WndProc , detect the onclick
event, check for Enable and if so do not send the event to the parent.
Like this:

protected override void WndProc(ref Message m)
{
if (m.Msg == WM_XXXX && !this.Enabled)
return;
base.WndProc(ref m);
}
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

<ba*******************@gmail.comwrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
Hi!
I'm trying to implement custom button. But I don't want to extend
Button class.
I want to extend Control class.
I want to implement Enable disable functionality.
But unfortunatly when control is in Enable = false state the on click
event is not called but that event is passed to parent object.
How to convince my custom button class not to pass Click events to
parent classes when my class is in Disabled state?

Thanks in advance

Jul 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bob Bedford | last post by:
I've this code: function checkdate(FormSubmit){ alert(document.getElementById('Mois').value); if(eval(document.getElementById('Mois'))>0 && eval(document.getElementById('Annee'))>0){...
3
by: Alphonse Giambrone | last post by:
I am trying to enable/disable a requiredfieldvalidator on the client side and am generating an error. I had found some documentation on validation which states that I should be able to...
2
by: Dntc | last post by:
Hi All Is there anyway to enable/disable the toolbar buttons on the fly as like in MFC which helps centralizing this process?Let's i have a toolbar button ToolbarButtonSave which can be...
5
by: misiek | last post by:
Hi all. I would like to know if it is possible to dynamically enable/disable row editing in GridView control in ASP.NET 2.0. I am asking because this feature should be enabled/disable depending...
2
by: RootSpy2006 | last post by:
Hi All, Problem Definition: --------------------- Microsoft Wirelss Keyboard works in BIOS but does not work when booting into windows. Discovered Work-around: -----------------------------...
2
by: Steve_s | last post by:
Hi I have a number of control buttons and tabs on a main form which I would like to be disabled until a selection is made in a list box, after which the controls would be enabled. All of the...
2
by: rn5a | last post by:
In a shopping cart app, assume that a user has placed 4 orders (each order has a corresponding OrderID which will be unique). When he comes to MyCart.aspx, by default, the details of his last order...
2
by: Naushad | last post by:
Hi all, I am using the countinous form. I want to Enable/Disable the some fields for perticular records as per the following condition when open the form. I have written this code in "On Current...
3
by: sanndeb | last post by:
I want to enable/disable controls of a asp.net page against a logged in user's permission. say 'admin' & 'hr' can change user's birth date text-box in a page but others will see the text-box as...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.