I have an UltraGrid on a form. In designer mode, I am using the UltraGrid Designer to go in and set most of the columns to hidden. In the designer I am getting what I expect:
Then when I run the app, I am getting ALL the columns:
Any thoughts on why? For the record, the collection being displayed is in a hierarchical set of custom business objects where all the collections DO implement a custom ITypedList interface (See this post for clarification). I am wondering if the custom ITypedList might have something to do with it.
Sam
If the grid is losing the design-time layout, it's because something is not matching up. Either the column names or the key of the band must be different at run-time from what you assigned at run-time.
Either that or you are setting the DataSource/DataMember properties instead of calling SetDataBinding.
Interesting, I defined a custom set of columns with the option that I would provide a dataset at runtime.
The data source is a set of custom business objects, each containing a collection of other custom business objects. The actual data source is two levels deep from the controls top most BindingSource:
Customers -> Orders -> OrderLines (or in my case Scores)
So there is a BindingSource for Customers, one for Orders, and one for OrderLines. At runtime I am assigning the "OrderLines" BindingSource to the UltraGrid and at run time I am still getting ALL the columns.
Mind you, elsewhere in this application I am simply binding an UltraGrid to a DataSet, going in to the UltraGrid Designer and hiding the columns I want hidden and it works. Very strange it doesn't work here.
HOWTO:How can I define columns in the grid at Design-time and bind them at run-time so that some fields of the data are excluded from the grid?
No luck there :( But I am a BIG fan of writing code via GUI's rather then editors. I did use a test program that is using the custom ITypedList interface and that is hiding the columns correctly. Here is all the code I have written for the control:
public sealed partial class QuestionBoxDetailControl : UserControl, IDetailPanel
{
public static UserControl Create(TmplBldrDoc tmplBldrDoc)
QuestionBoxDetailControl control = new QuestionBoxDetailControl();
control._tmplBldrDoc = tmplBldrDoc;
control.aTQuestionBoxBindingSrc.DataSource = tmplBldrDoc.DetailItem;
return control;
}
private TmplBldrDoc _tmplBldrDoc;
public QuestionBoxDetailControl()
InitializeComponent();
public void Initialize(TmplBldrDoc tmplBldrDoc)
_tmplBldrDoc = tmplBldrDoc;
#region IDetailPanel Members
public string Title
get { return "Question Detail"; }
void IDetailPanel.UpdateData(TmplBldrDoc tmplBldrDoc, IDetailPanel newPanel)
Debug.Assert(newPanel.GetType().Equals(this.GetType()));
#endregion
My first suspicion would be that somewhere in your code (possibly in the InitializeLayout event handler), you are setting the column's Hidden property to false. The easiest way to confirm this is to search the source for the phrase ".Hidden = ".