We Value Your Privacy

We and our partners use technology such as cookies on our site to personalise content and ads, provide social media features, and analyse our traffic. Click below to consent to the use of this technology across the web. You can change your mind and change your consent choices at anytime by returning to this site.

Update Consent
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 ...
  1. Click the "Start" button in Windows and select the "Microsoft Visual Studio."

  2. 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.

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

  4. Dim my Line As New Line()

  5. myLine.Stroke = Brushes.LightSteelBlue

  6. myLine.X1 = 1

  7. myLine.X2 = 40

  8. myLine.Y1 = 1

  9. myLine.Y2 = 40

  10. myLine.HorizontalAlignment = HorizontalAlignment.Left

  11. myLine.VerticalAlignment = VerticalAlignment.Center

  12. myLine.StrokeThickness = 3

  13. myGrid.Children.Add(myLine)

  14. 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 ...