Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1833
Column order does not match bound dataset
posted

I've a data grid that is bound to a pivoted dataset at runtime and no schema has been set as I don't know the columns to be included at design time as they vary depending on user selection / database config.
The pivoted dataset is constructed from 3 datasets (columns, rows and values) and I have ensured that the ordering of the column in the constructed, pivoted, dataset are correct before binding. However, when bound, the grid re-orders the columns. I cannot determine what criteria is used for this.

As far as I'm concerned the data grid columns should appear in the same order as they are in the dataset. I know that there is a mechanism to re-order but why is this happening at all?

Properties set on my grid: -

      Me.UGResults.CausesValidation = False
      Me.UGResults.Cursor = System.Windows.Forms.Cursors.Default
      Me.UGResults.DisplayLayout.AutoFitColumns = True
      Me.UGResults.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No
      Me.UGResults.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.[True]
      Me.UGResults.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.[True]
      Me.UGResults.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.[False]
      Me.UGResults.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortSingle
      Me.UGResults.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.[Single]
      Me.UGResults.Dock = System.Windows.Forms.DockStyle.Fill
      Me.UGResults.Location = New System.Drawing.Point(5, 5)
      Me.UGResults.Name = "UGResults"
      Me.UGResults.Size = New System.Drawing.Size(754, 102)
      Me.UGResults.TabIndex = 11

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    The grid gets the data structure (and thus the columns and their order) from the BindingManager. This is usually the same order as the columns int the data table and I have never seen it come out any other way, but if the order of the columns is not the same, it must be the BindingManager that is re-ordering them.

    In any case, you have total control of the order of columns in the grid via the column.Header.VisiblePosition property. The InitializeLayout event is a good place to set this.

Children