I am extending one of your button controls to have more properties and am including the following code to "Shadow" the Paint event to further draw a string below the main string. This works but would like to know if there is a better way of doing this, because when i change the text or hide and show the button, the text messes up during paint until it gets focus causing it to re-paint. Here is what the buttons looks like painted:
buttons.gif
and here is my code in my extended class:
Any thoughts for improvement or somewhere that might be more efficient?
buttons.gif
and here is my code in my extended class:
Private Shadows Sub ExtendedPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint | |
If Not String.IsNullOrEmpty(Me._alt_text) Then '_alt_text (string property) | |
Dim f1 As Font = New Font("Arial", 8.0F, FontStyle.Bold) | |
Dim sf As New StringFormat() | |
Dim brush As System.Drawing.Brush = New SolidBrush(Me._alt_text_color) | |
Dim rect As Rectangle = New Rectangle(e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height - 7) | |
sf.Alignment = StringAlignment.Center | |
sf.LineAlignment = StringAlignment.Far | |
e.Graphics.DrawString(Me._alt_text, f1, brush, rect, sf) | |
brush.Dispose() | |
sf.Dispose() | |
f1.Dispose() | |
End If | |
End Sub |
Any thoughts for improvement or somewhere that might be more efficient?