Live Chat Icon For mobile
Live Chat Icon

How do I draw a line in VB7 as there is no Line command as there was in VB6

Platform: WinForms| Category: from VB6

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 and/or it repaints, this line will *not* be redrawn.

(from sburke_online@microsoft..nospam..com on microsoft.public.dotnet.framework.windowsforms)

Another possible solution that has a design-time element is to use a label with height 1 and FixedSingle Border.
(suggested by Mark Lewis in microsoft.public.dotnet.framework.windowsforms)

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.