473,473 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to Prevent the Click Event when a Button is Clicked

When I click a button I don't want the click event to fire. Is this
possible?

In fact, what I would really like is to be able to intercept the click
event, perform some action, and then prevent the click from passing through
to the button.

Any help or suggestions much appreciated.

Charles
Nov 20 '05 #1
24 7602
Why don't you just remove or condition the code from the Click event?

The button will do nothing by itself.

--
Klaus H. Probst, MVP
http://www.vbbox.com/

"Charles Law" <bl***@nowhere.com> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
When I click a button I don't want the click event to fire. Is this
possible?

In fact, what I would really like is to be able to intercept the click
event, perform some action, and then prevent the click from passing through to the button.

Any help or suggestions much appreciated.

Charles

Nov 20 '05 #2
Hi Klaus

I actually have a lot of buttons, and text boxes, and dropdowns, and so on
that I want to do this for. To condition the code in every single one would
be tedious and repetitive.

I am really looking for the principle so that I can apply it to other types
of control as well. For example, I also want to prevent a dropdown from
dropping down, and prevent the button from appearing depressed when it is
clicked. In a nutshell, I want the control to behave like it never got the
click / mouse down event.

Charles
"Klaus H. Probst" <us*******@vbbox.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Why don't you just remove or condition the code from the Click event?

The button will do nothing by itself.

--
Klaus H. Probst, MVP
http://www.vbbox.com/

"Charles Law" <bl***@nowhere.com> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
When I click a button I don't want the click event to fire. Is this
possible?

In fact, what I would really like is to be able to intercept the click
event, perform some action, and then prevent the click from passing

through
to the button.

Any help or suggestions much appreciated.

Charles


Nov 20 '05 #3
Well that's possible, you can simply inherit from the control itself and
make it do anything you want.

For example, you could put some code in the OnClick method and so your stuff
there and prevent things from bubbling up to the container.

But that assumes that you started there - it's going to be hard to retrofit
to your existing code, especially if you have a lot of it.
--
Klaus H. Probst, MVP
http://www.vbbox.com/
"Charles Law" <bl***@nowhere.com> wrote in message
news:e#*************@tk2msftngp13.phx.gbl...
Hi Klaus

I actually have a lot of buttons, and text boxes, and dropdowns, and so on
that I want to do this for. To condition the code in every single one would be tedious and repetitive.

I am really looking for the principle so that I can apply it to other types of control as well. For example, I also want to prevent a dropdown from
dropping down, and prevent the button from appearing depressed when it is
clicked. In a nutshell, I want the control to behave like it never got the
click / mouse down event.

Charles
"Klaus H. Probst" <us*******@vbbox.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Why don't you just remove or condition the code from the Click event?

The button will do nothing by itself.

--
Klaus H. Probst, MVP
http://www.vbbox.com/

"Charles Law" <bl***@nowhere.com> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
When I click a button I don't want the click event to fire. Is this
possible?

In fact, what I would really like is to be able to intercept the click
event, perform some action, and then prevent the click from passing

through
to the button.

Any help or suggestions much appreciated.

Charles



Nov 20 '05 #4
Hi Charles,

Seems like you want to create your own Control-Classes.

Do something like:

Namespace Law
Public Class myButton
Inherits System.Windows.Forms.Button

' Add your code
Namespace Law
Public Class myComboBox
Inherits System.Windows.Forms.ComboBox

' Add your code

Of course you have to fill in the details yourself, use attirbutes, etc.....

HTH,

Michael
Nov 20 '05 #5

"Charles Law" <bl***@nowhere.com> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
When I click a button I don't want the click event to fire. Is this
possible?
No. If there's an event handler, the event will fire.
In fact, what I would really like is to be able to intercept the click
event, perform some action, and then prevent the click from passing through to the button.


The click can "pass through" to the button all day long and nothing will
happen other than it will appear pressed and then unpressed. That's all the
button will do on its own. If you don't want YOUR CODE executed when a Click
event occurs, write more code to detect this condition and then simply DON'T
EXECUTE your code.
Nov 20 '05 #6
* "Charles Law" <bl***@nowhere.com> scripsit:
When I click a button I don't want the click event to fire. Is this
possible?

In fact, what I would really like is to be able to intercept the click
event, perform some action, and then prevent the click from passing through
to the button.


\\\
Imports System
Imports System.Windows.Forms

Public Class UserControl1
Inherits Button

Private m_Clickable As Boolean

Public Property Clickable() As Boolean
Get
Return m_Clickable
End Get
Set(ByVal Value As Boolean)
m_Clickable = Value
End Set
End Property

Protected Overrides Sub OnClick(ByVal e As EventArgs)
If Me.Clickable Then
MyBase.OnClick(e)
End If
End Sub
End Class
///

Then you can use this button instead of the standard Windows Forms
button. One possible extension would be to provide a 'BeforeClick'
event that passes in a 'BeforeClickEventArgs' object that provides a
'Cancel' property. If the event is handled and 'Cancel' is set to
'True', the 'Click' event would not be raised.

The code above will extend the standard button with a 'Clickable'
property. If this property is set to 'False', the 'Click' event won't
fire.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #7
Thanks again Klaus.

Along with the other responses, I think everyone is pointing in the same
direction: basically, I have to create my own control and inherit from
button, etc. As you suggest, though, I'm not starting from there, and retro
fitting is not really an option.

Ho hum.

Charles
"Klaus H. Probst" <us*******@vbbox.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Well that's possible, you can simply inherit from the control itself and
make it do anything you want.

For example, you could put some code in the OnClick method and so your stuff there and prevent things from bubbling up to the container.

But that assumes that you started there - it's going to be hard to retrofit to your existing code, especially if you have a lot of it.
--
Klaus H. Probst, MVP
http://www.vbbox.com/
"Charles Law" <bl***@nowhere.com> wrote in message
news:e#*************@tk2msftngp13.phx.gbl...
Hi Klaus

I actually have a lot of buttons, and text boxes, and dropdowns, and so on that I want to do this for. To condition the code in every single one

would
be tedious and repetitive.

I am really looking for the principle so that I can apply it to other

types
of control as well. For example, I also want to prevent a dropdown from
dropping down, and prevent the button from appearing depressed when it is clicked. In a nutshell, I want the control to behave like it never got the click / mouse down event.

Charles
"Klaus H. Probst" <us*******@vbbox.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Why don't you just remove or condition the code from the Click event?

The button will do nothing by itself.

--
Klaus H. Probst, MVP
http://www.vbbox.com/

"Charles Law" <bl***@nowhere.com> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
> When I click a button I don't want the click event to fire. Is this
> possible?
>
> In fact, what I would really like is to be able to intercept the click > event, perform some action, and then prevent the click from passing
through
> to the button.
>
> Any help or suggestions much appreciated.
>
> Charles
>
>



Nov 20 '05 #8
Hi Michael

Seems like I *don't* really want to create my own class, but it seems that
it is my only option :-(

There has to be another way, doesn't there?

Charles
"Michael Maes" <mi*****@merlot.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Charles,

Seems like you want to create your own Control-Classes.

Do something like:

Namespace Law
Public Class myButton
Inherits System.Windows.Forms.Button

' Add your code
Namespace Law
Public Class myComboBox
Inherits System.Windows.Forms.ComboBox

' Add your code

Of course you have to fill in the details yourself, use attirbutes, etc.....
HTH,

Michael

Nov 20 '05 #9
Hi Jeff

As I mentioned, I have a lot of controls already, and retro-fitting
conditional code will be problematic. I even favour the inheritance route at
this stage, but I'm not happy.

But, I will persevere.

Charles
"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:e8**************@TK2MSFTNGP09.phx.gbl...

"Charles Law" <bl***@nowhere.com> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
When I click a button I don't want the click event to fire. Is this
possible?
No. If there's an event handler, the event will fire.
In fact, what I would really like is to be able to intercept the click
event, perform some action, and then prevent the click from passing

through
to the button.


The click can "pass through" to the button all day long and nothing will
happen other than it will appear pressed and then unpressed. That's all

the button will do on its own. If you don't want YOUR CODE executed when a Click event occurs, write more code to detect this condition and then simply DON'T EXECUTE your code.

Nov 20 '05 #10
Hi Herfried

I was beginning to think I had become invisible. I seem to have a lot of
posts unanswered at the moment - I don't suppose you would care to take a
look?

Anyway, back to the point. A good solution if I had started from there, but
as you may have gathered from my other replies, I haven't.

I wonder how the IDE does it, or SharpDevelop, for that matter. I have
looked at their code but I will never find it in there; there's loads of it.

There must be a way, surely, of intercepting the mouse events, or by using
an API?

Charles
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2l************@uni-berlin.de...
* "Charles Law" <bl***@nowhere.com> scripsit:
When I click a button I don't want the click event to fire. Is this
possible?

In fact, what I would really like is to be able to intercept the click
event, perform some action, and then prevent the click from passing through to the button.


\\\
Imports System
Imports System.Windows.Forms

Public Class UserControl1
Inherits Button

Private m_Clickable As Boolean

Public Property Clickable() As Boolean
Get
Return m_Clickable
End Get
Set(ByVal Value As Boolean)
m_Clickable = Value
End Set
End Property

Protected Overrides Sub OnClick(ByVal e As EventArgs)
If Me.Clickable Then
MyBase.OnClick(e)
End If
End Sub
End Class
///

Then you can use this button instead of the standard Windows Forms
button. One possible extension would be to provide a 'BeforeClick'
event that passes in a 'BeforeClickEventArgs' object that provides a
'Cancel' property. If the event is handled and 'Cancel' is set to
'True', the 'Click' event would not be raised.

The code above will extend the standard button with a 'Clickable'
property. If this property is set to 'False', the 'Click' event won't
fire.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #11
Charles,
Have you considered placing a window (control) over the top of your control
that shows the original control, but this second control eats all the mouse
clicks?

Unfortunately I don't have a good .NET example of how to do this, maybe a
Transparent or opaque control will do it...

Hope this helps
Jay

"Charles Law" <bl***@nowhere.com> wrote in message
news:uE**************@TK2MSFTNGP10.phx.gbl...
Hi Michael

Seems like I *don't* really want to create my own class, but it seems that
it is my only option :-(

There has to be another way, doesn't there?

Charles
"Michael Maes" <mi*****@merlot.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Charles,

Seems like you want to create your own Control-Classes.

Do something like:

Namespace Law
Public Class myButton
Inherits System.Windows.Forms.Button

' Add your code
Namespace Law
Public Class myComboBox
Inherits System.Windows.Forms.ComboBox

' Add your code

Of course you have to fill in the details yourself, use attirbutes,

etc.....

HTH,

Michael


Nov 20 '05 #12
Hi Jay

Yes, I had as it happens, but we all know how good GDI+ is at doing
transparent. ;-)

I think that this is by far the best solution because it takes care of
absolutely everything underneath by masking it. If only there was a control
that I could use, that would show the stuff below, but, as you say, eat the
mouse clicks.

Do you have one in mind?

Charles
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Charles,
Have you considered placing a window (control) over the top of your control that shows the original control, but this second control eats all the mouse clicks?

Unfortunately I don't have a good .NET example of how to do this, maybe a
Transparent or opaque control will do it...

Hope this helps
Jay

"Charles Law" <bl***@nowhere.com> wrote in message
news:uE**************@TK2MSFTNGP10.phx.gbl...
Hi Michael

Seems like I *don't* really want to create my own class, but it seems that it is my only option :-(

There has to be another way, doesn't there?

Charles
"Michael Maes" <mi*****@merlot.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Charles,

Seems like you want to create your own Control-Classes.

Do something like:

Namespace Law
Public Class myButton
Inherits System.Windows.Forms.Button

' Add your code
Namespace Law
Public Class myComboBox
Inherits System.Windows.Forms.ComboBox

' Add your code

Of course you have to fill in the details yourself, use attirbutes,

etc.....

HTH,

Michael



Nov 20 '05 #13
Charles,
As I stated I do not have an example!

The closest I think of is to create a form and change the Form.Opacity value
to 0. Place this second form over the first, this second form will get all
the mouse clicks...

However as I stated I DO NOT have an working example!

Ideally you want a control that does not paint ANYTHING, so the window below
it shows through...

Hope this helps
Jay
"Charles Law" <bl***@nowhere.com> wrote in message
news:OZ*************@TK2MSFTNGP11.phx.gbl...
Hi Jay

Yes, I had as it happens, but we all know how good GDI+ is at doing
transparent. ;-)

I think that this is by far the best solution because it takes care of
absolutely everything underneath by masking it. If only there was a control that I could use, that would show the stuff below, but, as you say, eat the mouse clicks.

Do you have one in mind?

Charles
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Charles,
Have you considered placing a window (control) over the top of your

control
that shows the original control, but this second control eats all the

mouse
clicks?

Unfortunately I don't have a good .NET example of how to do this, maybe a
Transparent or opaque control will do it...

Hope this helps
Jay

"Charles Law" <bl***@nowhere.com> wrote in message
news:uE**************@TK2MSFTNGP10.phx.gbl...
Hi Michael

Seems like I *don't* really want to create my own class, but it seems

that it is my only option :-(

There has to be another way, doesn't there?

Charles
"Michael Maes" <mi*****@merlot.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> Hi Charles,
>
> Seems like you want to create your own Control-Classes.
>
> Do something like:
>
> Namespace Law
> Public Class myButton
> Inherits System.Windows.Forms.Button
>
> ' Add your code
>
>
> Namespace Law
> Public Class myComboBox
> Inherits System.Windows.Forms.ComboBox
>
> ' Add your code
>
>
>
> Of course you have to fill in the details yourself, use attirbutes,
etc.....
>
> HTH,
>
> Michael
>
>



Nov 20 '05 #14
Charles,

* "Charles Law" <bl***@nowhere.com> scripsit:
I was beginning to think I had become invisible. I seem to have a lot of
posts unanswered at the moment - I don't suppose you would care to take a
look?

Anyway, back to the point. A good solution if I had started from there, but
as you may have gathered from my other replies, I haven't.

I wonder how the IDE does it, or SharpDevelop, for that matter. I have
looked at their code but I will never find it in there; there's loads of it.


\\\
Imports System
Imports System.Windows.Forms

Public Class UserControl1
Inherits Control

Private Declare Auto Function GetWindowLong Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nIndex As Int32) As Int32
Private Declare Auto Function SetWindowLong Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nIndex As Int32, ByVal dwNewLong As Int32) As Int32

Private Const GWL_EXSTYLE As Int32 = -20
Private Const WS_EX_TRANSPARENT As Int32 = &H20

Public Sub New()
SetStyle(ControlStyles.SupportsTransparentBackColo r, True)
Me.BackColor = Color.Transparent
End Sub

Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
Dim nStyle As Int32 = GetWindowLong(Me.Handle, GWL_EXSTYLE)
nStyle = nStyle Or WS_EX_TRANSPARENT
Call SetWindowLong(Me.Handle, GWL_EXSTYLE, nStyle)
End Sub

Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs)
'
End Sub
End Class
///

Add an instance of this class to your form's controls and place it in
front of all other controls.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #15
Herfried. I'm all out of superlatives, so a simple thank you. A fine answer.

Charles
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2l************@uni-berlin.de...
Charles,

* "Charles Law" <bl***@nowhere.com> scripsit:
I was beginning to think I had become invisible. I seem to have a lot of
posts unanswered at the moment - I don't suppose you would care to take a look?

Anyway, back to the point. A good solution if I had started from there, but as you may have gathered from my other replies, I haven't.

I wonder how the IDE does it, or SharpDevelop, for that matter. I have
looked at their code but I will never find it in there; there's loads of
it.
\\\
Imports System
Imports System.Windows.Forms

Public Class UserControl1
Inherits Control

Private Declare Auto Function GetWindowLong Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nIndex As Int32) As Int32 Private Declare Auto Function SetWindowLong Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nIndex As Int32, ByVal dwNewLong As Int32) As Int32
Private Const GWL_EXSTYLE As Int32 = -20
Private Const WS_EX_TRANSPARENT As Int32 = &H20

Public Sub New()
SetStyle(ControlStyles.SupportsTransparentBackColo r, True)
Me.BackColor = Color.Transparent
End Sub

Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
Dim nStyle As Int32 = GetWindowLong(Me.Handle, GWL_EXSTYLE)
nStyle = nStyle Or WS_EX_TRANSPARENT
Call SetWindowLong(Me.Handle, GWL_EXSTYLE, nStyle)
End Sub

Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs) '
End Sub
End Class
///

Add an instance of this class to your form's controls and place it in
front of all other controls.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #16
No need for Interop.

\\\
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or WS_EX_TRANSPARENT
Return cp
End Get
End Property
///

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Nov 20 '05 #17
Hi Mick

Which bit does this replace, or does it replace it all?

Charles
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
No need for Interop.

\\\
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or WS_EX_TRANSPARENT
Return cp
End Get
End Property
///

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004

Nov 20 '05 #18
Hi Charles

This method does not improve on Herfrieds, it just does away with InterOp.
The Class will look as follows:

\\\
Public Class UserControl1
Inherits UserControl

Private Const WS_EX_TRANSPARENT As Int32 = &H20

Public Sub New()
SetStyle(ControlStyles.SupportsTransparentBackColo r, True)
Me.BackColor = Color.Transparent
End Sub

Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or WS_EX_TRANSPARENT
Return cp
End Get
End Property

Protected Overrides Sub OnPaintBackground(ByVal pevent As
PaintEventArgs)
'
End Sub

End Class
///
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Charles Law" <bl***@nowhere.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi Mick

Which bit does this replace, or does it replace it all?

Charles


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Nov 20 '05 #19
* "Mick Doherty" <EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> scripsit:
No need for Interop.

\\\
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or WS_EX_TRANSPARENT
Return cp
End Get
End Property
///


That's the better solution, indeed.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #20
Thanks Mick. It makes sense to avoid the interop if it is not necessary, so
I will use your suggestion.

Charles
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:%2******************@TK2MSFTNGP10.phx.gbl...
Hi Charles

This method does not improve on Herfrieds, it just does away with InterOp.
The Class will look as follows:

\\\
Public Class UserControl1
Inherits UserControl

Private Const WS_EX_TRANSPARENT As Int32 = &H20

Public Sub New()
SetStyle(ControlStyles.SupportsTransparentBackColo r, True)
Me.BackColor = Color.Transparent
End Sub

Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or WS_EX_TRANSPARENT
Return cp
End Get
End Property

Protected Overrides Sub OnPaintBackground(ByVal pevent As
PaintEventArgs)
'
End Sub

End Class
///
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Charles Law" <bl***@nowhere.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi Mick

Which bit does this replace, or does it replace it all?

Charles


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004

Nov 20 '05 #21
Mick (& Herfried),
That's a keeper! I knew it was relatively easy, I just could not figure out
the words.

Hopefully I will remember where I kept it, the next time someone asks ;-)

Jay

"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
No need for Interop.

\\\
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or WS_EX_TRANSPARENT
Return cp
End Get
End Property
///

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004

Nov 20 '05 #22
It's a good solution for this problem, however if you want to draw in the
window so as to make some parts Opaque or Semi Transparent, then you'll find
that there is a problem with zOrder painting, which is why I usually create
Shaped controls.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Oq*************@tk2msftngp13.phx.gbl...
Mick (& Herfried),
That's a keeper! I knew it was relatively easy, I just could not figure out the words.

Hopefully I will remember where I kept it, the next time someone asks ;-)

Jay

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Nov 20 '05 #23
I have done something similar with a combo box that I wanted to extend.
It is pretty easy to search and replace the variable declaration and
instance instantiation lines in the code. You could add a property like
Clickable with a default value of false, etc, and then when you want to
make all your buttons unclickable cycle through them and set their
Clickable property to false. It didn't end up being too bad for my
case.
Michael Isaacs - MCP

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #24
Hi Michael

I have settled on the idea from Herfried. Putting a transparent window in
front of my control does the trick. It is even easier as all my controls
inherit from my base control, so I only have to implement it in the base
class for it to work.

Thanks again.

Charles
"Michael Isaacs" <ga*****@example.com> wrote in message
news:O%******************@TK2MSFTNGP09.phx.gbl...
I have done something similar with a combo box that I wanted to extend.
It is pretty easy to search and replace the variable declaration and
instance instantiation lines in the code. You could add a property like
Clickable with a default value of false, etc, and then when you want to
make all your buttons unclickable cycle through them and set their
Clickable property to false. It didn't end up being too bad for my
case.
Michael Isaacs - MCP

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #25

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

Similar topics

6
by: Sally | last post by:
I need to be able to click in a subform and run code but at the same time I need to be able to scroll the records without running the code. I tried coding the Enter event of the subform control but...
1
by: Stan | last post by:
If a page has a button with event handler private void btnAdd_Click(object sender, System.EventArgs e) { ....... } this event handler fires every time I refresh the page in the browser with...
2
by: Liqun Xu | last post by:
Hallo NG, I created a Button with Click-Event dynamically: System.Web.UI.WebControls.Button bt_1 = new Button(); bt_1.Click += new EventHandler(bt_1_click); and I implemented the Funktion...
5
by: J McD | last post by:
Hi I have a DataGrid with an ImageButton column. When I click on an imagebutton I get a postback but it doesn't run the OnImgBtnClick method. I can actually comment out the line where I add this...
0
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it...
2
by: Chu | last post by:
Thanks everyone for taking a moment to read this. I've got a page where I use a LinkButton and I wire up a dynamic event to the button. When the user clicks the button, the event is fired as...
2
by: Rob Roberts | last post by:
Is there any way to prevent a ButtonField in a GridView from doing a postback when clicked? I want to use my own onclick handler to call window.open('SomePage.aspx') to display a page in a new...
11
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked....
5
by: Diane Truyens | last post by:
Hi, I have a form with textboxes, a search button and a gridview. The textboxes are filled with default values so that the gridview should return all rows but not before the user has had the...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.