DATAGRIDVIEW does not display list of objects -- why not?

Why does the Datagrid not display the values?  (Winforms application.)
Public Class PFFAFormClass
    Public PFFAFormName As String
    Public OCFNO As String
    Public NoteType As String
    Public IndexMethod As String
End Class


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim pfc As New PFFAFormClass

        pfc.NoteType = "CH"
        pfc.OCFNO = "3013"
        pfc.PFFAFormName = "Test Form"
        pfc.IndexMethod = ""

        Dim lst As New List(Of PFFAFormClass)
        lst.Add(pfc)

        Me.DataGridView1.DataSource = lst

        Me.DataGridView1.Refresh()


End Sub

Open in new window

codefingerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Trideep PatelProject LeadCommented:
Make property for your variables and it will works
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim pfc As New PFFAFormClass

        pfc._NoteType = "CH"
        pfc._OCFNO = "3013"
        pfc._PFFAFormName = "Test Form"
        pfc._IndexMethod = ""

        Dim lst As New List(Of PFFAFormClass)
        lst.Add(pfc)
     
        Me.DataGridView1.DataSource = lst


        Me.DataGridView1.Refresh()


    End Sub


End Class

Public Class PFFAFormClass
    Public PFFAFormName As String
    Public Property _PFFAFormName() As String
        Get
            Return PFFAFormName
        End Get
        Set(ByVal value As String)
            PFFAFormName = value
        End Set
    End Property
    Public OCFNO As String
    Public Property _OCFNO() As String
        Get
            Return OCFNO
        End Get
        Set(ByVal value As String)
            OCFNO = value
        End Set
    End Property

    Public NoteType As String
    Public Property _NoteType() As String
        Get
            Return NoteType
        End Get
        Set(ByVal value As String)
            NoteType = value
        End Set
    End Property
    Public IndexMethod As String

    Public Property _IndexMethod() As String
        Get
            Return IndexMethod
        End Get
        Set(ByVal value As String)
            IndexMethod = value
        End Set
    End Property   

End Class

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
codefingerAuthor Commented:
If no one else answers, you (trideep) get the points, but I do not think I should have to make the change you suggest.  Public variables in the class SHOULD work with the datagrid, unless I am overlooking something.  What am I overlooking?

0
codefingerAuthor Commented:
The reason I thought public properties should work without get and set was because I did have that working for some other lists, however in that case the list was the property of another object, which somehow made GETS and SETS available to the datagrid automatically...still working out the details but this IS the RIGHT answer.....so THANKS!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.