Ok, I spent an hour or two (or more ;-)) banging my head on the desk trying to figure out how to draw a line on a form when it was loading only to discover that it is not possible (because the form is not yet loaded at that time so it is not possible to draw something at that point). So, as a quick test, I used the form paint sub as follows:
This works ok for the first line, but I am going to have a form that is going to have many dynamic objects (essentially everything below the first title line will be dynamic). What I'm trying to wrap my head around is a method that I can use to create the lines where I will actually need them (the example above is just the line under the headers at the top of the page). I am listing out a series of floors by building and want to separate each floor by a line in between. But, since I don't know how many occupants will be on a given floor, I have to draw the line after I've created the floor/building as a whole. Would I just create a new function that will be called after the form is visible and, if so, how would I reference the spots where the lines will need to be?
I just want to understand what I need to do so any advice or links would be great. I'm using VS2003 and .NET 1.1 if that makes any difference. Thanks!
------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
Code:
Private Sub frmReport_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Create a Pen object.
Dim pen As New Drawing.Pen(System.Drawing.Color.Black, 1)
Me.CreateGraphics.DrawLine(pen, 0, 60, 1000, 60)
pen.Dispose()
End Sub
I just want to understand what I need to do so any advice or links would be great. I'm using VS2003 and .NET 1.1 if that makes any difference. Thanks!
------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill