Besides querying the Text property, how do you find out which button on
the toolbar has been clicked? The Name property doesn't appear in the
code window, but only appears in the design mode.
The problem is that I have added a lot of spaces to the left of the
label of one of my buttons. The actual label text I have entered in the
design mode is " Exit Map".
When I query this:
else if (e.Button.Text. Trim() == "Exit Map")
{
this.Dispose();
this.Close();
}
The code skips this condition altogether. For the other labels, it
enters the construct as it should. I am a bit confused. 6 939
My bad! I had an extra space in between the two words.
I couldn't duplicate your problem, my code worked just fine, but to avoid it
you could use the TAG property instead.
HTH
WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
"Water Cooler v2" wrote:
Besides querying the Text property, how do you find out which button on
the toolbar has been clicked? The Name property doesn't appear in the
code window, but only appears in the design mode.
The problem is that I have added a lot of spaces to the left of the
label of one of my buttons. The actual label text I have entered in the
design mode is " Exit Map".
When I query this:
else if (e.Button.Text. Trim() == "Exit Map")
{
this.Dispose();
this.Close();
}
The code skips this condition altogether. For the other labels, it
enters the construct as it should. I am a bit confused.
"Water Cooler v2" <wt*****@yahoo. comwrote in message
news:11******** **************@ m79g2000cwm.goo glegroups.com.. .
Besides querying the Text property, how do you find out which button on
the toolbar has been clicked? The Name property doesn't appear in the
code window, but only appears in the design mode.
The problem is that I have added a lot of spaces to the left of the
label of one of my buttons. The actual label text I have entered in the
design mode is " Exit Map".
When I query this:
else if (e.Button.Text. Trim() == "Exit Map")
{
this.Dispose();
this.Close();
}
The code skips this condition altogether. For the other labels, it
enters the construct as it should. I am a bit confused.
What may be easier is to use code similar to this:
else if (myToolBar.Butt ons.IndexOf(e.B utton) = 1); // Or whatever the index
of your 'Exit Map' button is.
That way, if you change the text on the button, you won't need to worry
about changing the code.
Cheers,
Chris.
Chris is right, but I would disagree. It is far more likely that I would add
a button, thereby having to go and change all my "IndexOf" statements, than
have to change the text of a button a user is already using.
If you use the Tag property you avoid both problems, since the tag won't be
seen by the user, and I can assign a unique value to each and never have to
worry about adding buttons OR changing indexes.
IMHO of course ;)
WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
"ChrisM" wrote:
>
"Water Cooler v2" <wt*****@yahoo. comwrote in message
news:11******** **************@ m79g2000cwm.goo glegroups.com.. .
Besides querying the Text property, how do you find out which button on
the toolbar has been clicked? The Name property doesn't appear in the
code window, but only appears in the design mode.
The problem is that I have added a lot of spaces to the left of the
label of one of my buttons. The actual label text I have entered in the
design mode is " Exit Map".
When I query this:
else if (e.Button.Text. Trim() == "Exit Map")
{
this.Dispose();
this.Close();
}
The code skips this condition altogether. For the other labels, it
enters the construct as it should. I am a bit confused.
What may be easier is to use code similar to this:
else if (myToolBar.Butt ons.IndexOf(e.B utton) = 1); // Or whatever the index
of your 'Exit Map' button is.
That way, if you change the text on the button, you won't need to worry
about changing the code.
Cheers,
Chris.
>
else if (e.Button.Text. Trim() == "Exit Map")
{
this.Dispose();
this.Close();
}
Unless you're adding tool bar buttons dynamically at run-time, just
give all of your buttons descriptive names and compare the object
references:
ToolBarButton _button1;
..
..
..
if( e.Button == _button1 )
{
DoStuff();
}
Hmmm,
Thinking about it, I have to agree that using Tag is probably the best
maintenance friendly option :-)
Chris.
"WhiteWizar d" <Wh*********@di scussions.micro soft.comwrote in message
news:C2******** *************** ***********@mic rosoft.com...
Chris is right, but I would disagree. It is far more likely that I would
add
a button, thereby having to go and change all my "IndexOf" statements,
than
have to change the text of a button a user is already using.
If you use the Tag property you avoid both problems, since the tag won't
be
seen by the user, and I can assign a unique value to each and never have
to
worry about adding buttons OR changing indexes.
IMHO of course ;)
WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
"ChrisM" wrote:
>> "Water Cooler v2" <wt*****@yahoo. comwrote in message news:11******* *************** @m79g2000cwm.go oglegroups.com. ..
Besides querying the Text property, how do you find out which button on
the toolbar has been clicked? The Name property doesn't appear in the
code window, but only appears in the design mode.
The problem is that I have added a lot of spaces to the left of the
label of one of my buttons. The actual label text I have entered in the
design mode is " Exit Map".
When I query this:
else if (e.Button.Text. Trim() == "Exit Map")
{
this.Dispose();
this.Close();
}
The code skips this condition altogether. For the other labels, it
enters the construct as it should. I am a bit confused.
What may be easier is to use code similar to this:
else if (myToolBar.Butt ons.IndexOf(e.B utton) = 1); // Or whatever the index of your 'Exit Map' button is.
That way, if you change the text on the button, you won't need to worry about changing the code.
Cheers,
Chris. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andy Bates |
last post by:
I have hopefully a simple problem in C#.
I designed a form with a listview on left, vert splitter against that, then
the remainder of the form from top to bottom: a listview, horiz splitter and
tab control (very similar to outlook express).
I then started coding and realised that I needed to add a ToolBar. When I
added this, it didn't appear at the top as expected, but at the top of the
tab control and I couldn't get it to appear where...
|
by: none |
last post by:
hiho@ll
i want to make a IE Toolbar which has a newsticker built in
the problem i have is i don't really know how to use static text in a
toolbar?
the second question will be, how can i change the text of the label
randomly?
the problem i have:
i didn't write the toolbar and i'm not an expert on this topic ;-)
|
by: John |
last post by:
Hi all,
My app is using the toolbar webcontrol. Adding to and removing from the
toolbar is fine but I want to add something like an 'onclick' event to a
particular toolbaritem I'm adding to the toolbar so that it invokes a
javascript function but only for that image. How do I do this? I see that
the toolbar item does not have an 'attributes' attribute.
Regards
John.
|
by: Stewart |
last post by:
Pressing a Save Button on a Toolbar will not bind or validate the last value entered in a text box.
I have found that when clicking on the Toolbar the focus in the binded text box does not leave. Therefore in this case not saving the last entry when saving.
I am able to use the following code to get round the updating of the object from the field value with this code before saving
Private m_Record As Customer
.......
Private Sub...
|
by: =?Utf-8?B?L2Rldi9udWxs?= |
last post by:
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
| |
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,...
|
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...
|
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,...
|
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...
|
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...
|
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();...
| |
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |