Results 1 to 2 of 2

Thread: Can't Access Custom Property

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fox, OK
    Posts
    381

    Can't Access Custom Property

    I created a new DataGridViewColumn type called DataGridViewGradeColumn.

    Code:
    Public Class DataGridViewGradeColumn
        Inherits DataGridViewTextBoxColumn
        Public Property AssignmentName As String
        Public Property AssignmentType As String
        Public Property AssingmentPerfectScore As Integer
    End Class
    Then I mad a DataGridView (called grd), added some columns to it, and tried to access on of the new column properties.

    Code:
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            grd.RowCount = 5
        End Sub
    
        Private Sub btnNewColumn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewColumn.Click
            grd.Columns().Add(New DataGridViewGradeColumn)
            Dim i As Integer = grd.ColumnCount - 1
            grd.Columns(i).Width = 30
            grd.Columns(i).DefaultCellStyle.Alignment = ContentAlignment.MiddleRight
            'grd.Columns(i).AssignmentName = "some text"
        End Sub
    
        Private Sub btnGetRowTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetRowTotal.Click
            Dim r As Integer = grd.CurrentRow.Index
    
            Dim t As Integer = 0
            For c As Integer = 2 To grd.ColumnCount - 1
                t = t + CInt(grd.Item(c, r).Value)
            Next
            MsgBox(t.ToString)
        End Sub
    End Class
    l
    The new properties don't show up in intelisense.

    How do I access my custom properties?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Can't Access Custom Property

    Moved From The CodeBank which is for posting code to share rather than asking questions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width