Results 1 to 6 of 6

Thread: Tab char and menuitem

  1. #1

    Thread Starter
    Fanatic Member Arve K.'s Avatar
    Join Date
    Sep 2008
    Location
    Kyrksæterøra, Norway
    Posts
    518

    Tab char and menuitem

    Hi,

    Does anyone know about a "hack" to get the Tab char working in a ToolstripMenuItem/Label? I have tried Convert.ToChar(Keys.Tab), ControlChars.Tab... Even in C# using the "\t" character, the tab thing won't work. Instead of a "tab function", I only get 1 extra space in my text. If I put two tabs in the string, I get 2 extra spaces etc...

    It seem like the same thing applies to a Forms .Text property as well.

    I have tried building my string with all three (??) methods; String.Format, Interpolated strings and with the concatenation operator...
    Last edited by Arve K.; Feb 12th, 2018 at 07:22 AM.
    Arve K.

    Please mark your thread as resolved and add reputation to those who helped you solve your problem
    Disclaimer: I am not a professional programmer

  2. #2
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Tab char and menuitem

    I don't think so, short of custom rendering it yourself.

    Ask yourself this: "Have I ever purchased software that put a tab in this menu?" I don't think it's a good idea.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: Tab char and menuitem

    How about this... instead of explaining HOW you're trying to accomplish something... try explaining WHAT you're trying to do... what's the end goal here?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Fanatic Member Arve K.'s Avatar
    Join Date
    Sep 2008
    Location
    Kyrksæterøra, Norway
    Posts
    518

    Re: Tab char and menuitem

    Hi,

    My initial idea was to show a list of dropdown items (ToolstripLabels) where the .Text properties was showing some of my applications properties and their respective values lined neatly under each other (imagine a Listview with two columns and multiple rows, but without the headers)*. However, while awaiting responses here, I continued googling for answers elsewhere and it seems like this is difficult because how Winforms renders the labels text.

    * I would like the values in the red boxes to appear behind the green line
    Name:  toolstripmenu.png
Views: 245
Size:  6.3 KB

    I ended up making a UC that pops up when hovering over a ToolstripItem. Although this will cost me some extra hours, I can at least format the layout to my liking.

    I am still curious if it can be done though, since the route I went now is... cumbersome.
    Last edited by Arve K.; Feb 12th, 2018 at 01:06 PM.
    Arve K.

    Please mark your thread as resolved and add reputation to those who helped you solve your problem
    Disclaimer: I am not a professional programmer

  5. #5
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Tab char and menuitem

    In the language of Windows, menu items are meant to be simple phrases that correspond directly to commands. "Save". "Exit". "Print". These are words that do things, and it's not supposed to be confusing what happens if you click one.

    You might be able to display two words in a menu, so you could have "Option: Value" next to each other. But what's supposed to happen if the user clicks that option? The only logical thing I can think of is to display some Options dialog, but then that's the place where you can display all of the options and their values, so the whole menu could be replaced with an "Options..." item. That means doing this in a menu is awkward, even if it's visually convenient.

    I have seen menus that present ways to select Options, but they use the menu hierarchy. For example, you might have a "Font" menu, with a "Style" item. That "Style" item will have sub-items "Bold", "Italic", and "Underline", and the sub-menu can display a checkmark next to which items are enabled. The user can change the font style using these items. But expert users would very much rather learn keyboard shortcuts than use menu hierarchies for common things, so that is a consideration to make.

    I haven't seen something like you're describing before, which tells me A) it's probably hard to do and B) the above analysis is probably true and it's less convenient for the average user than it seems.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  6. #6
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,206

    Re: Tab char and menuitem

    If your wanting to display information in column form then you would need to use a Fixed Width Font, like Courier New. Then create the string value for each menu item by concatenating the values and the appropriate amount of spaces between them.

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