Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Two dropdown columns with same binding property
posted

Hello,

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?

  Regards,

Massimo Franzosi

Parents
  • 21795
    Offline posted

    Hello Massimo,

    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.

    CAS-171984-S9X6L7.zip
Reply Children