How to add a Property To a System Defined Class VB.NET
<p>Lets just say i want to add a property to a class such as <code>DataGridViewColumn</code>.</p>

<p>Is there such a way to do this that i can cast these objects to lets say <code>DataGridViewCheckBoxColumn</code> This is currently what i am doing but is giving me an error.</p>

<p>I have my own class <code>DataGridViewColumn</code></p>

<pre><code>Public Class DataGridViewColumn
Inherits System.Windows.Forms.DataGridViewColumn

Private Field As String
Public Property SomeField() As String
    Get
        Return Field
    End Get
    Set(ByVal value As String)
        Field = value
    End Set
End Property
End Class
</code></pre>

<p>Which is fine and works how i want it to. But when i go try something like this... It does not like it</p>

<pre><code>Private Function gen(name As String) As DataGridViewColumn
        Select Case name
            Case "DataGridViewTextBoxColumn"
                Dim c2 As New DataGridViewTextBoxColumn
                c2.Name = "tstColumn"
                c2.HeaderText = "Test Column"
                c2.ReadOnly = False
                Return c2
        End Select
        Return Nothing
    End Function
</code></pre>

<p>Is there any way to allow me to do this? I have also tried making a <code>DataGridViewTextBoxColumn</code> Class and inherting the <code>System.Windows.Forms.DataGridViewTextBoxColumn</code> but nothing seems to work.</p>

<p>Error simply says Cannot be converted to type DataGridViewColumn even when i have my own DataGridViewTextBoxColumn</p>