473,804 Members | 3,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hidden buttons in toolbar can still be clicked, how come ?

Hello,
i am using visual studio 2003 enterprise architect version. I am making
apps for the .Net framework 1.1. While testing an interface, i discovered
something strange.

In this application we have a standard toolbar that is at the top of the
form window. It contains about 8 buttons that use images from an imagelist.
Sometimes we hide buttons thru the code.

When a button is hidden, i assumed that it wasn't clickable. It appears
that horizontally across the toolbar, the top 2 pixels become some sort of
button. When i click at the top of the toolbar where normally there
shouldn't be anything, it activates one of the hidden buttons. To the eye,
everything seems fine but when i click in this area it generates a
ToolBar.ButtonC lick event and e.button contains the properties of the hidden
button.

How come ? I've tried to search the web but couldn't find anything.
Dec 6 '07 #1
6 3905
On Dec 6, 10:40 am, /dev/null <devn...@discus sions.microsoft .com>
wrote:
Hello,
i am using visual studio 2003 enterprise architect version. I am making
apps for the .Net framework 1.1. While testing an interface, i discovered
something strange.

In this application we have a standard toolbar that is at the top of the
form window. It contains about 8 buttons that use images from an imagelist.
Sometimes we hide buttons thru the code.

When a button is hidden, i assumed that it wasn't clickable. It appears
that horizontally across the toolbar, the top 2 pixels become some sort of
button. When i click at the top of the toolbar where normally there
shouldn't be anything, it activates one of the hidden buttons. To the eye,
everything seems fine but when i click in this area it generates a
ToolBar.ButtonC lick event and e.button contains the properties of the hidden
button.

How come ? I've tried to search the web but couldn't find anything.
Just hiding a button (setting the Visible property to False) does not
disable it. You need to also set the Enabled property to False.
Dec 6 '07 #2
** Just hiding a button (setting the Visible property to False) does not
disable it. You need to also set the Enabled property to False.**

Uh? I'm with zacks on this one. If you hide it, there is nothing to click
on. I've just tried it. However, I get a Toolbar Click event, not a
ButtonClick Event.

-Jerry

<za***@construc tion-imaging.comwrot e in message
news:55******** *************** ***********@w40 g2000hsb.google groups.com...
On Dec 6, 10:40 am, /dev/null <devn...@discus sions.microsoft .com>
wrote:
>Hello,
i am using visual studio 2003 enterprise architect version. I am making
apps for the .Net framework 1.1. While testing an interface, i
discovered
something strange.

In this application we have a standard toolbar that is at the top of the
form window. It contains about 8 buttons that use images from an
imagelist.
Sometimes we hide buttons thru the code.

When a button is hidden, i assumed that it wasn't clickable. It appears
that horizontally across the toolbar, the top 2 pixels become some sort
of
button. When i click at the top of the toolbar where normally there
shouldn't be anything, it activates one of the hidden buttons. To the
eye,
everything seems fine but when i click in this area it generates a
ToolBar.Button Click event and e.button contains the properties of the
hidden
button.

How come ? I've tried to search the web but couldn't find anything.

Just hiding a button (setting the Visible property to False) does not
disable it. You need to also set the Enabled property to False.

Dec 6 '07 #3
On Dec 6, 12:20 pm, "Jerry Spence1" <Jerry.Spe...@a sdfasdf.comwrot e:
** Just hiding a button (setting the Visible property to False) does not
disable it. You need to also set the Enabled property to False.**

Uh? I'm with zacks on this one. If you hide it, there is nothing to click
on. I've just tried it. However, I get a Toolbar Click event, not a
ButtonClick Event.

-Jerry
Well, I spoke too soon on this. Turns out the click event for the
toolstrip button does not fire if the control is merely set to not
visible. BUT, if you have and Click event handler for the Toolstrip
itself, then, yes, if you click on the toolstrip where the invisible
button is, the toolstrip's Click event WILL fire.
>
<za...@construc tion-imaging.comwrot e in message

news:55******** *************** ***********@w40 g2000hsb.google groups.com...
On Dec 6, 10:40 am, /dev/null <devn...@discus sions.microsoft .com>
wrote:
Hello,
i am using visual studio 2003 enterprise architect version. I am making
apps for the .Net framework 1.1. While testing an interface, i
discovered
something strange.
In this application we have a standard toolbar that is at the top of the
form window. It contains about 8 buttons that use images from an
imagelist.
Sometimes we hide buttons thru the code.
When a button is hidden, i assumed that it wasn't clickable. It appears
that horizontally across the toolbar, the top 2 pixels become some sort
of
button. When i click at the top of the toolbar where normally there
shouldn't be anything, it activates one of the hidden buttons. To the
eye,
everything seems fine but when i click in this area it generates a
ToolBar.ButtonC lick event and e.button contains the properties of the
hidden
button.
How come ? I've tried to search the web but couldn't find anything.
Just hiding a button (setting the Visible property to False) does not
disable it. You need to also set the Enabled property to False.
Dec 6 '07 #4
Seems i didn't explain it properly.

Here is some code :
Private Sub ToolBar1_Button Click(ByVal sender As System.Object, ByVal e
As System.Windows. Forms.ToolBarBu ttonClickEventA rgs) Handles
ToolBar1.Button Click
If e.Button Is Me.NewButton Then
MsgBox("New")
ElseIf e.Button Is Me.CopyButton Then
MsgBox("Copy")
ElseIf e.Button Is Me.CutButton Then
MsgBox("Cut")
ElseIf e.Button Is Me.HelpButton Then
MsgBox("Help")
End If
End Sub

I am talking about the buttonclick event of a toolbar.

When i hide one button and leave the 3 others, strange things will happen.

I tried it in a new project and the problem duplicates.

If i click on the toolbar where no button is, this event is generally not
fired and nothing happens, which is what i want.

However, and here is the catch, if i click at the top of the toolbar, in a
zone of about 2 pixels high and that covers the whole width of my form, the
event is fired and the content of e.Button is the hidden button. You can't
see a delimitation for this zone but it catches clicks.

I've shown it to other devs here and no one seems to know what is causing
this.

This is really strange, the original button is just 16x16 or 32x32 pixels.

Thanks a lot for taking the time to help me out.

"za***@construc tion-imaging.com" wrote:
On Dec 6, 12:20 pm, "Jerry Spence1" <Jerry.Spe...@a sdfasdf.comwrot e:
** Just hiding a button (setting the Visible property to False) does not
disable it. You need to also set the Enabled property to False.**

Uh? I'm with zacks on this one. If you hide it, there is nothing to click
on. I've just tried it. However, I get a Toolbar Click event, not a
ButtonClick Event.

-Jerry

Well, I spoke too soon on this. Turns out the click event for the
toolstrip button does not fire if the control is merely set to not
visible. BUT, if you have and Click event handler for the Toolstrip
itself, then, yes, if you click on the toolstrip where the invisible
button is, the toolstrip's Click event WILL fire.

<za...@construc tion-imaging.comwrot e in message

news:55******** *************** ***********@w40 g2000hsb.google groups.com...
On Dec 6, 10:40 am, /dev/null <devn...@discus sions.microsoft .com>
wrote:
>Hello,
>i am using visual studio 2003 enterprise architect version. I am making
>apps for the .Net framework 1.1. While testing an interface, i
>discovered
>something strange.
>In this application we have a standard toolbar that is at the top of the
>form window. It contains about 8 buttons that use images from an
>imagelist.
>Sometimes we hide buttons thru the code.
>When a button is hidden, i assumed that it wasn't clickable. It appears
>that horizontally across the toolbar, the top 2 pixels become some sort
>of
>button. When i click at the top of the toolbar where normally there
>shouldn't be anything, it activates one of the hidden buttons. To the
>eye,
>everything seems fine but when i click in this area it generates a
>ToolBar.Button Click event and e.button contains the properties of the
>hidden
>button.
>How come ? I've tried to search the web but couldn't find anything.
Just hiding a button (setting the Visible property to False) does not
disable it. You need to also set the Enabled property to False.
Dec 6 '07 #5
On Dec 6, 4:03 pm, /dev/null <devn...@discus sions.microsoft .com>
wrote:
Seems i didn't explain it properly.

Here is some code :
Private Sub ToolBar1_Button Click(ByVal sender As System.Object, ByVal e
As System.Windows. Forms.ToolBarBu ttonClickEventA rgs) Handles
ToolBar1.Button Click
If e.Button Is Me.NewButton Then
MsgBox("New")
ElseIf e.Button Is Me.CopyButton Then
MsgBox("Copy")
ElseIf e.Button Is Me.CutButton Then
MsgBox("Cut")
ElseIf e.Button Is Me.HelpButton Then
MsgBox("Help")
End If
End Sub

I am talking about the buttonclick event of a toolbar.

When i hide one button and leave the 3 others, strange things will happen.

I tried it in a new project and the problem duplicates.

If i click on the toolbar where no button is, this event is generally not
fired and nothing happens, which is what i want.

However, and here is the catch, if i click at the top of the toolbar, in a
zone of about 2 pixels high and that covers the whole width of my form, the
event is fired and the content of e.Button is the hidden button. You can't
see a delimitation for this zone but it catches clicks.

I've shown it to other devs here and no one seems to know what is causing
this.

This is really strange, the original button is just 16x16 or 32x32 pixels.

Thanks a lot for taking the time to help me out.

"za...@construc tion-imaging.com" wrote:
On Dec 6, 12:20 pm, "Jerry Spence1" <Jerry.Spe...@a sdfasdf.comwrot e:
** Just hiding a button (setting the Visible property to False) does not
disable it. You need to also set the Enabled property to False.**
Uh? I'm with zacks on this one. If you hide it, there is nothing to click
on. I've just tried it. However, I get a Toolbar Click event, not a
ButtonClick Event.
-Jerry
Well, I spoke too soon on this. Turns out the click event for the
toolstrip button does not fire if the control is merely set to not
visible. BUT, if you have and Click event handler for the Toolstrip
itself, then, yes, if you click on the toolstrip where the invisible
button is, the toolstrip's Click event WILL fire.
<za...@construc tion-imaging.comwrot e in message
>news:55******* *************** ************@w4 0g2000hsb.googl egroups.com...
On Dec 6, 10:40 am, /dev/null <devn...@discus sions.microsoft .com>
wrote:
Hello,
i am using visual studio 2003 enterprise architect version. I am making
apps for the .Net framework 1.1. While testing an interface, i
discovered
something strange.
In this application we have a standard toolbar that is at the top of the
form window. It contains about 8 buttons that use images from an
imagelist.
Sometimes we hide buttons thru the code.
When a button is hidden, i assumed that it wasn't clickable. It appears
that horizontally across the toolbar, the top 2 pixels become some sort
of
button. When i click at the top of the toolbar where normally there
shouldn't be anything, it activates one of the hidden buttons. To the
eye,
everything seems fine but when i click in this area it generates a
ToolBar.ButtonC lick event and e.button contains the properties of the
hidden
button.
How come ? I've tried to search the web but couldn't find anything.
Just hiding a button (setting the Visible property to False) does not
disable it. You need to also set the Enabled property to False.
Is there some reason why you are using the Toolbar ButtonClick event
to handle all toolbar button's being clicked instead of each button's
own Click event?
Dec 6 '07 #6
Seems i just can't proceed this way. I tried to define the event handler in
vb.net and the dropdown list in the vb.net interface lets me handle the
disposed event and that's it. I tried to define the event handler manually
and i get Event 'Click' cannot be found.

From what i understand, i have to use the ToolBar.ButtonC lick event.

I can fix the problem by removing the unwanted buttons from the toolbar in
the form.load event but the whole behavior with hidden buttons seemed so
strange.

Your suggestion was brilliant though as i really didn't think of that.

I'm still seeking explanations on why this behavior occurs with my toolbars
(it occurs in the app i'm developing and in the test form i made too).

Thanks a lot for taking all this time to answer my question.

"za***@construc tion-imaging.com" wrote:
On Dec 6, 4:03 pm, /dev/null <devn...@discus sions.microsoft .com>
wrote:
Seems i didn't explain it properly.

Here is some code :
Private Sub ToolBar1_Button Click(ByVal sender As System.Object, ByVal e
As System.Windows. Forms.ToolBarBu ttonClickEventA rgs) Handles
ToolBar1.Button Click
If e.Button Is Me.NewButton Then
MsgBox("New")
ElseIf e.Button Is Me.CopyButton Then
MsgBox("Copy")
ElseIf e.Button Is Me.CutButton Then
MsgBox("Cut")
ElseIf e.Button Is Me.HelpButton Then
MsgBox("Help")
End If
End Sub

I am talking about the buttonclick event of a toolbar.

When i hide one button and leave the 3 others, strange things will happen.

I tried it in a new project and the problem duplicates.

If i click on the toolbar where no button is, this event is generally not
fired and nothing happens, which is what i want.

However, and here is the catch, if i click at the top of the toolbar, in a
zone of about 2 pixels high and that covers the whole width of my form, the
event is fired and the content of e.Button is the hidden button. You can't
see a delimitation for this zone but it catches clicks.

I've shown it to other devs here and no one seems to know what is causing
this.

This is really strange, the original button is just 16x16 or 32x32 pixels.

Thanks a lot for taking the time to help me out.

"za...@construc tion-imaging.com" wrote:
On Dec 6, 12:20 pm, "Jerry Spence1" <Jerry.Spe...@a sdfasdf.comwrot e:
** Just hiding a button (setting the Visible property to False) does not
disable it. You need to also set the Enabled property to False.**
Uh? I'm with zacks on this one. If you hide it, there is nothing to click
on. I've just tried it. However, I get a Toolbar Click event, not a
ButtonClick Event.
-Jerry
Well, I spoke too soon on this. Turns out the click event for the
toolstrip button does not fire if the control is merely set to not
visible. BUT, if you have and Click event handler for the Toolstrip
itself, then, yes, if you click on the toolstrip where the invisible
button is, the toolstrip's Click event WILL fire.
<za...@construc tion-imaging.comwrot e in message
news:55******** *************** ***********@w40 g2000hsb.google groups.com...
On Dec 6, 10:40 am, /dev/null <devn...@discus sions.microsoft .com>
wrote:
>Hello,
>i am using visual studio 2003 enterprise architect version. I am making
>apps for the .Net framework 1.1. While testing an interface, i
>discovered
>something strange.
>In this application we have a standard toolbar that is at the top of the
>form window. It contains about 8 buttons that use images from an
>imagelist.
>Sometimes we hide buttons thru the code.
>When a button is hidden, i assumed that it wasn't clickable. It appears
>that horizontally across the toolbar, the top 2 pixels become some sort
>of
>button. When i click at the top of the toolbar where normally there
>shouldn't be anything, it activates one of the hidden buttons. To the
>eye,
>everything seems fine but when i click in this area it generates a
>ToolBar.Button Click event and e.button contains the properties of the
>hidden
>button.
>How come ? I've tried to search the web but couldn't find anything.
Just hiding a button (setting the Visible property to False) does not
disable it. You need to also set the Enabled property to False.

Is there some reason why you are using the Toolbar ButtonClick event
to handle all toolbar button's being clicked instead of each button's
own Click event?
Dec 7 '07 #7

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

Similar topics

8
17308
by: Matt Herson | last post by:
I have been trying to find a way to use JavaScript to change the value of a hidden field on submit. I am already invoking a JavaScript to handle the validation on submit. The reason I need to change this field is some of the forms have two buttons on them, each needs to process the form differently. If I can change the value of the hidden field dynamically it will solve my issue as I can run each against a diffent cgi. Currently my...
3
2118
by: Trythat | last post by:
Is it possible to tell which button has been clicked, when using the right mouse button (using the mousedown event). I can tell which button using the 'ToolBar_ButtonClick' but I want to tell whether it was a left or right mouse button click. I've searched Google, but surprisingly there isn't anything on there, so any help received with thanks.
3
2540
by: Michael C | last post by:
How on earth do you disable ToolBar Buttons and change the images on ToolBar buttons at run-time? Thanks, Michael C.
2
1944
by: RN | last post by:
I am dynamically adding a number of HTML buttons to a page... <input type="submit" name="alwaysthesame" id="different1" value="alwaysthesame"> <input type="submit" name="alwaysthesame" id="different2" value="alwaysthesame"> <input type="submit" name="alwaysthesame" id="different3" value="alwaysthesame"> I want them all to have the same name NAME attribute and the same VALUE
3
1568
by: Tom Williams | last post by:
Surely there must be some way to refer to a button on a toolbar by its name. I don't mean when the button is clicked, I can see how to do that. Depending on what's going on, I want to enable or disable certain buttons. For example, it the user hasn't done anything, disable the "cancel" button. After they start typing, enable the "Cancel" button. When there's nothing to
1
7734
by: zwieback89 | last post by:
Hi, I have a org tree with hierarchical display of employees built using classic asp and vbscript. I also have list of radio buttons for report names. I have 1 select box with dates in it. Then I click on the submit button to view the reports in Crystal. But
11
5347
by: dana1 | last post by:
I have a form which contains some buttons. The buttons use some of the standard images that come with access 2003 (e.g., the move next record image, or the sort ascending/descending images). The default behavior for access is to give the button a "highlighted" appearance when the button is hovered with the mouse. My problem is that these buttons permanently have that "highlighted" appearance after they have been clicked. With my XP theme,...
2
2692
by: 9icj4u613jeqrx8 | last post by:
Hi, I need some help with IE browser programming (in .NET). I'm trying to add a button to the IE toolbar, and on the click of the button open a popup window with a remote URL. Secondly, I'm trying to highlight certain predefined words on particular web sites through the IE plugin itself. To add an IE button, I've found this neat article:
5
7347
by: dmorand | last post by:
I'm having a strange issue with a form I'm developing. I'm saving some values to hidden fields when a user clicks a button. I setup a function which gets ran on submission of the form, but I also placed this function on my submission button when clicked. <input name="button5" type="button" class="Buttons" id="button5" value="On File" OnClick="setup_req('cpr_onfile',1);"/> <input type="hidden" name="cert_onfile"/> ..... <cfform...
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
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
10568
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
10323
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9138
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
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
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.