DataGridView column order does not seem to work

前端 未结 4 528
再見小時候
再見小時候 2020-12-20 21:20

I have a DataGridView bound to a list of business objects:

Dim template As New IncidentTemplate
Dim temps As List(Of IncidentTemplate) = template.LoadAll
Dim         


        
4条回答
  •  抹茶落季
    2020-12-20 21:41

    The AutoCreateColumn is the problem. The following article gives an example for how to fix it.

    From DataDridView DisplayOrder Not Working

    When setting the column’s DisplayIndex in a data grid view, some columns were out of order. To fix the issue, I had to set AutoGenerateColumns to true before setting the data source, and to FALSE after.

    For Example:

    dgvReservedStalls.AutoGenerateColumns = True
    dgvReservedStalls.DataSource = clsReservedStalls.LoadDataTable()
    dgvReservedStalls.AutoGenerateColumns = False
    

提交回复
热议问题