DISCOVER
×
Loading ...

How to Draw a Grid on a Panel in VB.NET

Updated April 17, 2017

The Visual Basic for ASP.NET (VB.NET) is a part of the Windows Presentation Foundation (WPF) in the Microsoft .NET Framework. WPF gives software developers the ability to access multiple graphics layers and presentation controls in the VB.NET programs. Shape objects are the top layer of the graphics presentation. It enables you to draw the objects, such as the ellipse, rectangle and grid line on the screen. They can be located inside of the panel form and most of VB.NET controls. You need to define the line element properties to draw a grid line on a panel in VB.NET.

Loading ...

Click the "Start" button in Windows and select the "Microsoft Visual Studio."

Click the "Open" and select the Visual Basic ASP.NET (VB.NET) program you want to use to draw a grid line on a panel.

Add the following code after the "protected override" line in your VB.NET program:

Dim my Line As New Line()

myLine.Stroke = Brushes.LightSteelBlue

myLine.X1 = 1

myLine.X2 = 40

myLine.Y1 = 1

myLine.Y2 = 40

myLine.HorizontalAlignment = HorizontalAlignment.Left

myLine.VerticalAlignment = VerticalAlignment.Center

myLine.StrokeThickness = 3

myGrid.Children.Add(myLine)

Click the "File," "Save" to add the function of drawing a grid line on a panel in your VB.NET program.

Loading ...

About the Author

Alexander Gokhfeld has been writing since 2002. He has written for the monthly business publications "AutoPublish" and "MGRealty." Gokhfeld holds certification in business intelligence infrastructure development as well as a Bachelor of Science in electric engineering from Urban Trans College.

Loading ...