Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

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.
1 Solution
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)


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now