Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles _
MyBase.Paint
' Create the text we will display.
Dim txt As String = ""
txt &= "Bacon Burger" & vbTab & "3.00" & vbCrLf
txt &= vbTab & "Tomato" & vbTab & "0.15" & vbCrLf
txt &= vbTab & "Extra Cheese" & vbTab & "0.20" & vbCrLf
txt &= "Large Fries" & vbTab & "0.99" & vbCrLf
txt &= "Medium Softdrink" & vbTab & "1.05" & vbCrLf
txt &= "" & vbCrLf
txt &= "Subtotal" & vbTab & "5.39" & vbCrLf
txt &= "Tax" & vbTab & vbTab & "0.38" & vbCrLf
txt &= "Total" & vbTab & vbTab & "5.77" & vbCrLf
' Make a LayoutRectangle that coves the form.
Dim layout_rect As New RectangleF( _
Me.ClientRectangle.Left, _
Me.ClientRectangle.Top, _
Me.ClientRectangle.Width, _
Me.ClientRectangle.Height)
' Create a StringFormat that defines the tab stops.
Dim string_format As New StringFormat
Dim tab_stops() As Single = {30, 130 - 30}
string_format.SetTabStops(0, tab_stops)
' Clear and draw the text.
e.Graphics.Clear(Me.BackColor)
e.Graphics.DrawString(txt, Me.Font, _
Brushes.Black, layout_rect, string_format)
' Show where the tabs are.
e.Graphics.DrawLine(Pens.Red, 30, 0, 30, _
Me.ClientSize.Height)
e.Graphics.DrawLine(Pens.Red, 130, 0, 130, _
Me.ClientSize.Height)
End Sub
|