I'm trying to replace the standard Datagridview with Ultragrid in our application. In our DataGridView we usually have two dropdown columns, one for item code and one for item description, both bound to the same property (the item key) in a dataset. So in the first dropdown you have the codes alphabetically ordered and in the second dropdown the descriptions. If you choose one value in a dropdown, the other is set to the correnspondent value depending on the selected key. This is possible in a datagridview because it allows you to bind different columns to the same property via DataPropertyName. In Ultragrid I can't see something like DataPropertyName, but just the Column Key, and you can't set the same Key on different columns. How can we reproduce this scenario using Ultragrid?
Thank you for posting in our forum.
First of all, in order to place a dropdown combo in a cell of UltraGrid you need to assign to its ValueList property an instance of object implementing IValueList interface. Please check the following article where you may find more information related to best practices for placing a dropdown in UltraGrid cell http://blogs.infragistics.com/winforms/wiki/best-practices-for-placing-a-dropdown-or-combo-in-an-wingrid-cell/5.aspx.
If I understand correctly, in your case you need two columns with dropdown cells. Both columns refer to the same data, but one shows what is in CODES column and the second one what is in the DESCRIPTION column. One possible solution in this case is to create two ValueLists, add the necessary items to each one, and assign them to the appropriate column. In the attached sample project I have shown how you can implement this.
One more thing. To synchronize the values of both columns you may handle the CellChange event of the grid. In the event handler of this event you can set the value of the other column when the value of the first one has changed. Check the attached sample where I have implemented this approach.
Please let me know if you need any additional information.
Thank you for using Infragistics Controls.
thank you for your reply. This is a good example, but I'm not sure we can adopt this approach. If an external event in the form changes the key value of the datasource, only the bound column would refresh. We should call a dedicated method to re-synchronize the values, but in terms of impact and maintenance costs I think this is not the best solution, considering the number of forms and events we have.
Thank you for your feedback.
I am not sure I am completely understanding your scenario. If you are able to send me a small sample project, showing what you are doing with DataGridView, I will be glad to investigate this further, and to try to offer you solution with Infragistics UltraGrid.
Looking forward to your reply.