473,702 Members | 2,651 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 3898
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
17301
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
2112
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
2533
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
1938
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
1564
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
7727
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
5321
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
2687
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
7341
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
8738
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
8652
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,...
1
8979
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8939
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
7829
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...
0
5907
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
4412
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
4667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2399
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.