asked on
Private Sub tsMenuItem_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles tsMenuItem.Paint
tsMenuItem.Text = String.Empty
tsMenuItem.AutoSize = False
' You may need to change this values (ajustments)
' -------------------------------------------------
Dim ItemHeight As Byte = 4
Dim ReduceGap As Byte = 8
' -------------------------------------------------
Dim strFirst As String = "R"
Dim sz As SizeF = e.Graphics.MeasureString(strFirst, tsMenuItem.Font, tsMenuItem.Width)
e.Graphics.DrawString(strFirst, tsMenuItem.Font, Brushes.Red, 0, ItemHeight)
Dim strSecond As String = "efresh"
e.Graphics.DrawString(strSecond, tsMenuItem.Font, Brushes.Black, sz.Width - ReduceGap, ItemHeight)
sz = e.Graphics.MeasureString(strFirst + strSecond, tsMenuItem.Font, 120)
tsMenuItem.Width = sz.Width
End Sub
ASKER
ASKER
Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.
TRUSTED BY
ASKER
That is very close to what I need, but I am having one problem. The font I am using is Arial, 22pt, style=Bold.
When the OnPaint finishes, the statusstrip height gets changed to 22 (caused from the .Autosize) and the text is cut off. If I turn off the autosize or adjust the statusstrip.height in the method, the form painting gets screwed up.