I am trying to convert a "DataGridView with design time bound combo boxes into an UltraGrid with the same features. I have the ultra grid and I set the column to "dropdownlist". Now I can't figure out how to bind the data. In the datagridview the columntype is set to combobox and the DataSource and DisplayMember point to the dataset and table/column to use for the list. In UltraWinGrid Designer I set the column's style to DropDownList, I set ButtonDisplayStyle to Always, but I can't figure out the equivalent values to point to the list values. I see ValueList - but it isn't giving me any selection options and all the help online shows setting this programmatically, not through the designer. Any feedback is appreciated!
Thanks for the great explanation. I have tried both approaches and it works great. Quick question, if I use approach 2, how do I determine what value the user selected from the Combo?
Hi corles,
If you have any further questions regarding this implementation, please let me know.
Sincerely,Chris KDeveloper Support EngineerInfragistics, Inc.www.infragistics.com/support
There are a few ways that you can achieve this behavior through the designer. The first would include creating a value list within the UltraGrid and assigning this list to the column in question, where you would be implementing the DropDownList as the display style.
The second approach would include using a discrete ultraCombo control and using it as the editor component for the desired column in your grid. In the latter approach, the ultraCombo would require its own DataSource. I will provide a brief walkthrough for both of these approaches, below.
Approach #1 – UltraGrid DropDown Column Populated by ValueList
Create a new project and add an UltraGrid as well as an UltraDataSource to the form. Note: In this example, the DataSource will contain one column and several rows, populated with arbitrary data.
Next, bind the UltraDataSource to the UltraGrid and access the properties menu of the UltraGrid. Select ‘DisplayLayout’ and nested within this properties list, you will find the ‘ValueLists’ collection.
Access the list by left clicking on the collection and then the associated ellipse. You will need to add atleast one member to the list, each of these members will represent a discrete value list. Once a member has been added, go ahead and access the ValueListItems collection within the member’s properties. Here you may add several members to this sub-collection, these members will represent the individual items to be displayed within the DropDownList.
After you have added some test items to the ValueListItems collection, save the modifications by selecting ‘OK’.
Next, select the Designer Dialog for the UltraGrid from within the Grid’s smart tag. Select ‘Band and Column Settings’, from the left pane of the designer and then select the first band ‘Band[0] – ‘Band 0’’, followed by the nested ‘Columns’ node.
If more than one column has been added to the DataSource, ensure that the correct column has been selected within the middle pane and then set it’s Style to ‘DropDownList’. Finally, set the column’s ValueList property to the one that we created earlier, (named valueList0 by default).
Approach#2 – Implement UltraGrid and UltraCombo controls, both populated by discrete DataSources
In this approach, you will need to add an UltraGrid as well as an UltraCombo to your form. Next, add two UltraDataSource components; one for the UltraGrid and the second to be bound to the UltraCombo. In the attached sample, I have populated a single column with multiple rows, containing arbitrary data for the demonstration.
Access the DataSource for both controls, assigning the desired ultraDataSource for each.
Next, access the Designer Dialog from the ultraCombo’s smart tag, select Band and Column Settings, from the left pane. Within the middle pane, select Column [Column 0], (if you have populated the UltraGrid with more than one column) and to the right, within the properties selection for Band[0] you will find the EditorComponent property. Set this to ‘ultraCombo1’.
It may also be a good time to set the ButtonDisplayStyle, so that the drop down button for the ultraCombo, (which will populate each cell within the first column) as by default, the drop down button will only appear while the mouse is hovered over the cell. This property may be set to ‘Always’, if you would like the drop down button even for idle cells to display, (cells which have the ultraCombo as their editor component).
By default, the column header for the ultraCombo will be displayed when it’s drop down menu is activated. In order to Hide the Column Header, within the ultraCombo, access the Designer Dialog from the ultraCombo’s smart tag, select Band and Column Settings, from the left pane. On the right, within the properties selection for Band[0] you will find a ColHeader property, which may be set to false.
The ultraCombo used as the editor component, which we used earlier to bind to the desired data source, may be hidden from view within the designer by right clicking on the control within the designer and selecting “Send To Back”, in order to free up canvas real-estate within the designer.
Please find the sample projects for both approaches attached; for further context.
If you have any questions about either of these solutions, please let me know.