Hi,
is there a way to let the user choose a value to input in a spreadsheet cell from a combobox?
Like the combobox cell type in the ultragridc control.
Thanks in advance.
Best,
Raul
Hello Raul,
In order to have a combobox or dropdown in the UltraSpreadsheet control, you need to define a ListValidationRule for the corresponding Worksheet’s cells in the Workbook that you assign to the spreadsheet and set its ShowDropdown property to true. The ListValidationRule object has a SetValues method that allows you to assign the values that appear in the drop-down, and then you can actually add the rule to the Worksheet by adding it to the DataValidationRules collection.
I am attaching a sample project that demonstrates the above. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
SpreadsheetDropDownList.zip
Hello Andrew,
I already tried the method outlined in your kind reply, but without any success.
Today, perusing the sample you provided I found out that it was because of a bug in release 16.2, which I'm using in my application.
I then tested with v18.2 and all was fine.
It would be nice to have not only a list of values in the combo, but also a value/description pair.
Are there any events that would allow me to handle what's displayed in the drop down list?
TIA.
Best regards
Thank you for your update on this matter.
At the moment, there is no “value/description” pair in the UltraSpreadsheet. Each of the values that are displayed in the combo are determined by you by the object[] that you provide to the ListDataValidationRule.SetValues method.
I am also curious as to what type of events you are looking for in this case, as the DataValidationRules.Add method takes a particular cell to apply the ListDataValidationRule to. As such, you can determine which cells should show which values by defining different ListDataValidationRules with different object[] objects for different cells.
If you would like to see a “value/description” pair type of functionality included in the UltraSpreadsheet control for the drop-down, I would recommend suggesting a new product idea for this. You can do this at our Windows Forms Ideas Site and this will place you in direct communication with our product management teams who plan and prioritize upcoming features and development based on community and user feedback.