Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27046

VS 2010 problem in work with datagridviewcolumns class

$
0
0
hi friends

i create a new class that inherits datagridview . my main purpose is to add a new property to all columns of this new datagridview .
my professor want that i do this in the form below . i explain to you all the steps and my problem :
1- i create a new class of DatagridviewColumns :

Code:

Public Class MyDatagridviewColumn
    Inherits DataGridViewColumn
    Dim MName As String
    Public Property MyNewProperty As String
        Get
            Return MName
        End Get
        Set(ByVal value As String)
            MName = value
        End Set
    End Property
End Class

2- i create a new class inherits of datagridview :
Code:

Public Class MyDatagriedview
    Inherits DataGridView

    Dim C1 As MyDatagridviewColumn
    Dim CC1 As DataGridViewColumnCollection

    Public Shadows Property Columns(ByVal Index As Integer) As MyDatagridviewColumn
        Get
            Return C1
        End Get
        Set(ByVal value As MyDatagridviewColumn)
            C1 = value
        End Set
    End Property
    Public Shadows Property Columns As DataGridViewColumnCollection
        Get
            Return CC1
        End Get
        Set(ByVal value As DataGridViewColumnCollection)
            CC1 = value
        End Set
    End Property
    Public Sub Initialize()
        C1 = New MyDatagridviewColumn
        CC1 = New DataGridViewColumnCollection(Me)
    End Sub
    Sub New()
        Initialize()
    End Sub
End Class

3- now i add it to my form in runtime and add on example column to it :
Code:

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim mdgv As New MyDatagriedview
        mdgv.Columns.Add("c1", "c2")
        Me.Controls.Add(mdgv)
    End Sub
End Class


but it dont work . form is load and a datagridview with no column is appear . what and where is the problem?

Viewing all articles
Browse latest Browse all 27046

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>