473,705 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9147
"ba************ *******@gmail.c om" 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(re f m);
}
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

<ba************ *******@gmail.c omwrote in message
news:11******** *************@p 79g2000cwp.goog legroups.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
9206
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){ document.forms.getElementByID('SELECTCONSTRUCTOR').disabled = false; //can't reach the control here } else
3
15958
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 enable/disable validators on the client side. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspplusvalid.asp According to it and the little other info I was able to find, the way to accomplish what I want it to call...
2
8664
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 enabled/disabled inside the Edit control TextChanged event handler?I'm looking for a way which Toolbar can ask itself to enable/disable its buttons as ON_UPDATE_COMMAND_UI in MFC?
5
19065
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 on button, which was clicked by user. Thanks in advance, misiek
2
8904
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: ----------------------------- 1.> Open Device Manager(The keyboard device will have an exclamation and
2
11239
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 controls display data or run reports which require a parameter which is passed to the underlying queries from aforementioned list box.....I would be gratefull if someone had a tidy way of achieving this.. Thanks
2
3223
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 he had placed will be displayed in a DataList. Also assume that the OrderID of the last order is 13. The details of the earlier orders placed by a particular user (when the user places more than 1 order) can be viewed by clicking links. The...
2
4376
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 Event". I go on the perticular record its enable/dosable the following field for all records. I have tried this code in "On Open Even" but there is no effect. Please help me to solve this problem.
3
3192
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 disabled. so i wrote a function like this public enum UserRoles { GroupLead = 0x2, WebAdmin = 0x4, Developers = 0x8, Hr = 0x10,
0
8689
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5933
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4439
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4703
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3137
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2486
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2081
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.