How to affect the way an extended control is instantiated

When the user instantiates my extended version of DataGridView I want it to have a certain number of rows and columns with various cell types. I know what to do just not where to put the code to do it.
Who is Participating?
you can add an overload to the constructor (Sub New()) in the derived class

Public MyClass
  Inherits Datagridview

  Public Sub New()
    InitializeMyGrid(5, 6)  ' Where 5 and 6 are the predefined grid size
  End Sub
  Public Sub New(Rows As Integer, Columns As Integer)
    InitializeMyGrid(Rows, Columns)
  End Sub

  Protected Sub InitializeMyGrid(Rows As Integer, Columns As Integer)
    ' Add the code to set the number of rows/columns
  End Sub
End Class

To instantiate
' To create a predefined gridsize
Dim myPDgrid As New myClass()

' To create a customize gridzie
Dim myCustGrid As New myClass(8,8)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.