DataGridView automatically generates columns

前端 未结 5 2021
没有蜡笔的小新
没有蜡笔的小新 2021-01-17 14:57

On my Windows Form I have a DataGridView component, which is bound to a BindingSource. The BindingSource is an object datasource to an EntityFramework object.

Some t

5条回答
  •  广开言路
    2021-01-17 15:44

    I had the same problem. I couldn't find the AutoGenerate property in my code.

    For reasons I do not understand my DataGridView does not have an AutoGenerate property that I can see in my VB code.

    I do not see a checkbox on the Edit Columns dialog box.

    I do not see an AutoGenerate property in the grid's properties view.

    I have Visual Studio Community 2017.

    Here's my class properties:

    Public Property BatchId As Integer
    Public Property Code as String
    Public Property Count As Integer
    Public Property Description As String
    Public Property Id As Integer

    So, here's what I did:

    1. I went to the form designer.
    2. I right-clicked on the DataGridView.
    3. I selected Edit Columns.
    4. I made sure each column had the DataPropertyName field set to the class property name.

    When I ran my application the DataGridView displayed only those columns in my class.

提交回复
热议问题