I have a form with an xtraGrid, where users can select from a list of tables that includes every major section of the application. The data is then shown in an xtraGrid, allowing them to sort, filter, and export the information in a report. Effectively, it's a one-stop-shop reporting tool for the entire application.
Obviously I need to be able to bind the xtraGrid to datasource at will, and update the xtraGrid bands and columns to match the new data. To do this, I start with a completely blank xtraGrid. No bands, no columns, no nothing. Everything is created at runtime.
Once the user selects a set of tables to view and presses a button, a provide the datasource they request. Then I begin to format the columns so everything looks pretty. I set the column headers, hide the columns they don't need to see, etc. Then I add bands into which I can group the columns, and add the columns into the bands.
Here is the part I'm having trouble with:[VB.NET]
'...(other columns that are NOT hidden are handled above, but cut for space.) .Columns("EPSDetail_Report").Visible = False .Columns("EPSDetail_Report").OptionsColumn.AllowShowHide = False .Columns("EPSDetail_Report").OptionsColumn.ShowInCustomizationForm = False Dim bandNewEPS As GridBand = gridNew.Bands.AddBand("EPS") bandNewEPS.Columns.Add(gridNew.Columns("EPSDetail_Description")) bandNewEPS.Columns.Add(gridNew.Columns("EPSDetail_Responsible")) bandNewEPS.Columns.Add(gridNew.Columns("EPSDetail_Status"))
As you can see, I add a band called "EPS". Then I add three columns to that band.
When the code executes the band is created, but the columns are not moved under the band. Instead, they remain in the column customizer. I have to manually drag them under the "EPS" band, where they appear correctly.
Obviously we don't want the user to have to manually drag his columns onto the grid, we want them to have a default setup. What could be causing this kind of issue?
Please remember that, while my example above only shows the column "EPSDetail_Report", and that column is hidden, columns "EPSDetail_Description", "EPSDetail_Responsible", and "EPSDetail_Status" are not hidden, are shown in the customizer, and should be appearing in the "EPS" band as the code displays.
To solve the issue, you need to explicitly set the Visible property:
..... viewNew.Columns("EPSDetail_Description").Visible = true 'at the end of your code
In addition, please note that it's better to wrap your code in the View.BeginUpdate/EndUpdate statement to improve its performance.
Let me know if you have additional questions.