Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I draw a line to replace the functionality of VB6's Line command?

Try this code:

Dim g as Graphics 
g = frmMain.CreateGraphics() 
g.DrawLine(Pens.Black, new Point(0,0), _
  new Point(frmMain.ClientRectangle.Width), frmMain.ClientRectangle.Height) 
g.Dispose()

This should draw a line from the upper left to the bottom right corner of your application, but only if it's visible. If this code isn't in the paint event, when something obscures your application or it repaints, this line will not be redrawn.

Shawn Burke, Microsoft



Page view counter