Results 1 to 4 of 4

Thread: [RESOLVED] [2008] ToolStripStatusBar Text cannot have special characters?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    252

    Resolved [RESOLVED] [2008] ToolStripStatusBar Text cannot have special characters?

    Hi All,

    What stumped me was: when I tried putting

    ToolStripStatusLabel1.Text = "Drag & Drop Files or press Browse".

    The text appeared as "Drag _Drop Files or press Browse".

    Obviously the & sign was missing.

    Is this a limitation or am I missing some setting/

    Thanks,
    Mcore

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] ToolStripStatusBar Text cannot have special characters?

    The ampersand is used to create mnemonics, e.g. you set the Text of a menu item to "&File" and the 'F' will then be underlined to indicate that that is the access key for the menu item. Pressing Alt+F will then invoke that menu item's Click event. What you've done is create a label whose access key is the space bar. If you want a literal ampersand in controls that support mnemonics then you need to escape the character with another ampersand:
    vb.net Code:
    1. ToolStripStatusLabel1.Text = "Drag && Drop Files or press Browse"
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    252

    Re: [2008] ToolStripStatusBar Text cannot have special characters?

    Thanks jmcilhinney, that explains the mystery. The status bar also displays the current file path which will be processed. So this means I will have to parse the file path string through a text replacement function to replace any & to &&.

    It kind of doesn’t make sense to have such thing in the status bar. It makes sense for a menu so when you press ALT you see what letter you want to press in order to access the menu.

    Cheers,
    McoreD

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] [2008] ToolStripStatusBar Text cannot have special characters?

    ToolStripStatusLabel derives from ToolStripLabel. Just like a regular Label, whose access key would select the next control in the Tab order, so too does the ToolStripLabel. The ToolStripStatusLabel just happens to inherit that behaviour. It's conceivable that it might be useful but very rarely, I agree. Just a side-effect you have to live with, unfortunately.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width