riceman0
asked on
ContextMenuStrip text alignment
So I am trying to right-align the text items on a context menu strip, but the code below doesn't seem to work, the items are still left-aligned. Is it possible to do this?
Thanks very much.
Thanks very much.
Dim cm As New ContextMenuStrip
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
cm.Items.Clear()
Dim tsmi As New ToolStripMenuItem("hello")
tsmi.TextAlign = ContentAlignment.MiddleRight
Dim tsmi2 As New ToolStripMenuItem("four score and seven years ago")
tsmi2.TextAlign = ContentAlignment.MiddleRight
Dim tsmi3 As New ToolStripMenuItem("abc")
tsmi3.TextAlign = ContentAlignment.MiddleRight
cm.Items.Add(tsmi)
cm.Items.Add(tsmi2)
cm.Items.Add(tsmi3)
End Sub
Private Sub Form2_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
cm.Show(Me, New Point(e.X, e.Y))
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, that did it!
You get the points, but maybe you know this too:
I am manually changing the width of the menu strip to match what I am opening it next to. I turn off AutoSize and set the width to the desired dimension.
The right-alignment of the text seems to be stuck on the original width (which turns out to be the middle of my strip). Do you have any idea how to force it to align to my manual width?
I've been trying different functions to force it but no luck yet.