Re: Toolbar question by ChrisM
ChrisM
Wed Jul 19 03:41:12 CDT 2006
Hmmm,
Thinking about it, I have to agree that using Tag is probably the best
maintenance friendly option :-)
Chris.
"WhiteWizard" <WhiteWizard@discussions.microsoft.com> wrote in message
news:C2F33915-E404-430C-B9C2-4B5B631EA7CE@microsoft.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" <wtr_clr@yahoo.com> wrote in message
>> news:1153232028.908090.186310@m79g2000cwm.googlegroups.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.Buttons.IndexOf(e.Button) = 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.
>>
>>
>>