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
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 = ".
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
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?
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.
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.
I have a feeling that your assumption is correct. I got word from others on another team that they, too, have seen the bug in the version we are using but that it is fixed in Vol 2. Now to get everyone on the same page to make the switch;)
Is it possible to have both Vol 1 and Vol 2 on my machine at one time?
Can we be expecting a Vol 3 anytime soon?
Hi Sam,
Since the project was already using NetAdvantage 2009 Vol 1., that is what I used when I tested it.
I, of course, used the latest internal build of the controls, though. So this was probably a bug that was fixed in a service release that you don't have.
Run it with NetAdvantage WinForms 2009 vol 1. Since I knew you would be running on the latest, Vol 2, I fired up my virtual machine that I have Vol 2 on, and gave it a try, and it is working fine. I just had a co-worker run the program (with Vol 1) and he is seeing it. All indications are pointing to the fact that this was fixed in Vol 2.
If you have a Vol 1 environment setup such that it is little trouble for you to test in the old environment, I would appreciate it. If it is going to take time for you to setup an Vol 1 environment, I don't think it worth the time.
When I open your sample in VS and look at the UserControl, I see three columns in the grid: TargetValue, ConditionId, and Score.
When I open the form, I see the same three columns.
When I run the application, I see the same three columns.
So what do I have to do to see the problem occur?
it is now happening to me on a second UltraGrid, this time a simple enough case I was able to pull it out into a small example. In the attached project, I have removed the columns from the user control but when I place the user control on the form, all the columns are being displayed again.