Add white space between 2 string values in ContextMenuStrip items (Windows Forms)

  • Thread starter Thread starter ChrisHar
  • Start date Start date
C

ChrisHar

Guest
I need to add the white space for that the 2nd string always stand under each other. I'm using a non monospaced font like here on the webpage. As you can see, the 3 is not exactly under the 9.

Audi 4
BMW 9
Mercedes 3

String.PadRight is not precise enough. I guess adding a space in SizeF (width) could be precise enough?!.

An other guy mentioned to use a custom ToolStripRenderer because the white space is always font depended.

1. Am i the first one who's trying to do that, any code snippets maybe or alternatives? (I'm trying to create a text builder for that a user can select an item's text to build his own combination of a virtual keyboard code within an application.)

2. If i wants to customize the ToolStrip which looks like a very hard task for me, i think i have to override the OnPaint of the ToolStripItem class and i'm depended on the limited methods for drawing a string what could be a problem again for adding a white space?

(ToolStripItem Class (System.Windows.Forms))


Regards

Continue reading...
 
Back
Top