I have a grid that is in an UnltraExpandableGroupBox. When my form loads, the group box is in the collapsed state. I would like to be able to change column headings runtime for the columns that I set up with the designer. It seems, though, that the columns aren't actually added to the grid until it is made visibile, i.e. when the group box is un-collapsed.
What can I do in order to dynamically change the column headings when the form is loading?
You can't use the grid unbound. I'd recommend creating a data source with the correct data structure but no rows and binding it to the grid initially, before any search is performed. Then you will be able to access the columns. Attempting to access any part of the data structure before the grid is bound to a data source will probably cause problems.
InitializeLayout doesn't go off until data is bound to the grid. But, columns that I set up at design time via the infragistics designer appear as soon as the grid is visible. I have a "search" form that uses the grid to show search results. When the grid first appears, its blank because the user hasn't searched for anything yet. My design time columns are all there. Data won't be bound to the grid until the user actually searches for something.
What I need to do is find a way to change the column headers dynamically. I need to be able to change the heading of a column (some customers might call it a doohickey, others might call it a thingamajig) at runtime. I can't seem to find when the columns are added to the grid. I see them being added in the VS designer-generated InitializeComponent method, but even after that method completes, grid.DisplayLayout.Bands[0].Columns.Count = 0. When do those columns actually get added to the grid so that I can mess with them?
Generally speaking you do this in the InitializeLayout event. I can't imagine why this would be any different when the grid is hidden, since the event fires when the data source is set.