Hi, I have an ultragrid which is taking as a datasource at runtime an arraylist of given objects.
I'm not the creator of these objects. I am only interested in displaying a few of their properties, which will be a few columns in my grid.
I created bound columns in my ultragrid, but as soon as the datasource is given to the grid, all the fields naturally create new columns automatically.
How do I properly insure that ONLY those few properties I'm interested in actually generate columns?
I know I could always browse the gridcolumns after the datasource is given and hide the unnecessary columns, but it doesn't seem clean at all. Can you give me the proper way to achieve this end?
Thanks.
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?
I´ve done al that it is said at the link you provided, but im stuck figuring out hoy to show unhidden columns.
I have a list with objects with 6 properties and i´m hidding 4 but just one is show that is a small text and the one that is not shown is a larger text phrases.
Tried defining at SetDataBinding the hiddenNewColumn parameter to false and all columns are shown with its data OK, so it is not a Binding to DataSource problem but i guess is a hiddenColumns mapping parameter issue.
Appreciate any help, its really frustating...
Sorry, what i meant is "not showing hidden columns", this are shown despite i select it to be hidden at the "Column Arrangement Designer".
I´ve resolved by including the "[System.ComponentModel.Browsable(false)]" annotation to the properties i wanted not to be show to the class data container, but i´m limited to the column title to be as the property name.
I´m checking the InitializeLayout event and it worked with a code as this:
private void grdProducerType_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { foreach (UltraGridColumn c in e.Layout.Bands[0].Columns.All) { switch (c.Key) { case "AlphanumericId": c.Hidden = false; c.Header.Caption = "Id"; break; case "Id": c.Hidden = true; break; case "CertificateType": c.Hidden = true; break; case "CertificateTypeDesc": c.Hidden = true; break; case "Description": c.Hidden = false; c.Header.Caption = "Descripción"; break; } } }
Thank you!
Hi,
I'm afraid I do not understand your explanation of what you are trying to do. What do you mean by "show unhidden columns?" If a column is not hidden, then it is already shown. So why would you have to show it?Did you mean "show hidden columns?" If you want to show a hidden column, then why hide it in the first place? All columns are shown by default, so what you have written here doesn't make sense.
If you want to determine what columns are shown in the grid, then the easiest way to do this is to handle the InitializeLayout event of the grid and set the Hidden property on each column. It's very simple and easy and bypasses all of the quirks of the form designer.