I am trying to create a WinForm that contains an UltraWinGrid that will contain rows of provisions. Each row contains critera for a provision (which printer, which paper size, et al.) Each criterion is a single selection from a list of possible selections (e.g. Printer1, Printer2, etc.). The possible selections are only known at runtime, so to select one I plan to create a ValueList of possibilities for each column, define each UltraWinGrid Band.Column.Style as a DropDownList, and assign the column.ValueList at runtime. A possible provisioning is:
Printer1 8x11 BondPrinter2 11x16 Bond
The selections available for all rows are the same, only the selection value for each row can be different. The value of each cell in the DataSource is an integer; I populate the ValueList with integer IDs and string DisplayText and want the DropDownList to display the text of the associated ID. Each row should be different, but let's not worry about that yet.
A screen shot of the UltraGrid properties follows:
(The editor removed my picture. It is available at http://tinypic.com/r/33o6xwg/6)
I cannot get this to work; trying to set the ValueList with:
ugAutoHold.DisplayLayout.Bands[0].Columns["Printer"].ValueList = targetPrinters;
Throws a null reference exception because ugAutoHold.DisplayLayout.Bands[0].Columns is always empty.
I have read http://es.infragistics.com/community/forums/t/67869.aspxbut cannot use that as my ValueLists are not know until runtime.
Hi,
So the question is, why is the columns collection empty?
What kind of DataSource are you using for your grid?
In what event are you attempting to set the ValueList on the column? I recommend using the InitializeLayout event for this if you are not already doing so. This will ensure that the columns have already been created since this event fires after the grid is bound to a data source.
I have made some progress, and seem to have some misconceptions. Can you tell me if the following is correct?
These are the conclusions I have come to after many hours of experimentation. I am not complaining, I just need to know if these are correct so I am not going down the wrong path.
Thanks for the quick reply. My dataSource is an ICollection<> of custom class instances with properties including PrinterID, SizeID, PaperID, ProductOptionID.
Just for giggles, I created a DataTable at runtime with the custom class columns, populated it with my data, and bound to that instead. Now the ugAutoHold.DisplayLayout.Bands[0].Columns are defined, but they contain the DataTable columns, not my grid DisplayLayout.Bands[0].Columns. A screenshot is at http://tinypic.com/r/2mzfeo8/6.
I notice now the DataSource columns are named "PrinterID" and such, while the Column[].Key properties are "Printer" and such. I will try matching names.
However, The DataTable I created has records and they are not displayed in the grid. At runtime my grid Rows.Count is zero. A DataTable is not useful to bind to anyway, since it contains only integer IDs and I need to show readable names looked up at runtime.
I am attempting to set the column ValueLists in my form constructor. I will try doing so in the InitializeLayout event.