troubleshooting Question

How do I convert this in a function? Only 10 lins of code, couldnt seem to find out how!

Avatar of Mezillinu
MezillinuFlag for Malta asked on
.NET ProgrammingVisual Basic.NET
8 Comments1 Solution196 ViewsLast Modified:
I am drawing a grid in a panel at the load, and am using the panels paint,

"handles panel1.paint"

I cannot seem to convert the code I did to create a grid, into a function so I could pass the column numbers and rows in a drop down lists or some other control, to give the user some flexibility.

can somebody help me out?  

What I could not get rid of is the E.

I want to pass the panel into it, so I could draw a grid in it, and pass column number, row number, row height and column width.

All help appreciated!

Regards
Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
        'Start drawing lines and continue adding your own styles
        Dim rowHeight As Integer = 16
        Dim rowCount As Integer = 100
        Dim columnWidth As Integer = 10
        Dim columnCount As Integer = 50
        For i As Integer = 0 To rowCount
            e.Graphics.DrawLine(Pens.Black, 0, i * rowHeight, columnCount * columnWidth, i * rowHeight)
        Next
        For j As Integer = 0 To columnCount
            e.Graphics.DrawLine(Pens.Black, (j * columnWidth), 0, (j * columnWidth), rowCount * rowHeight)
        Next
    End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros