Binding ComboBox

Posted by: patrick.muellner on 5 June 2023, 9:07 pm EST

    • Post Options:
    • Link

    Posted 5 June 2023, 9:07 pm EST

    Hi,

    I’ve following problem.

    Currently we work with the version 4.0.20181.588.

    We update now to 4.6.20231.784.

    Problem is, that with the new version, the selected item is set to nothing. I include you two videos. (old and new version)

    We don’t change anything in the code.

    Happens something with the binding??? It seems like the same thread https://www.grapecity.com/forums/wpf-edition/c1datetimepicker - it think something in binding changed?!?

    RegardsVideo_C1Combo.zip

  • Posted 6 June 2023, 6:34 pm EST

    Hi Patrick,

    Unfortunately, we could not replicate the issue on our end.

    We have attached a sample application for your reference. Please check ComboBoxBinding.zip

    We request you update the attached sample or provide a stripped-down version of the sample application that replicates the issue. This will help us understand your use-case scenario better and assist you accordingly.

    Thanks & Regards,

    Aastha

  • Posted 28 June 2023, 11:37 pm EST

    Hi,

    is it possible that something changes in the C1TabControl.

    Because every GUI Tests has problem where a ComboBox is in the C1TabControl?

    Regards

  • Posted 29 June 2023, 10:13 pm EST

    Hi Patrick,

    > is it possible that something changes in the C1TabControl.

    There could be a lot of changes in the APIs of v4.0 and v4.6.2 C1TabControl control.

    As per our understanding, you are facing some issues while using combobox inside C1TabControl. We created a sample application like this but could not find the issue. Please refer ComboBoxBinding_Mod.zip

    We are sorry but we are unable to understand your use-case scenario from the videos provided by you. Hence, we would appreciate if you could provide us with a small sample application that shows the behavior at your end. Otherwise, please update the attached sample so that we can have a better understanding of the issue.

    Thanks & Regards,

    Aastha

  • Posted 20 August 2023, 6:09 pm EST

    Hi,

    I think I know what happened.

    We have many code where the SelectedItem is set and if the SelectedItem is set the List (ItemsSource) is cleared and after that, the ItemsSource will be new created.

    With the version 4.0.20181.588 nothing happened, and everything works fine. With the newest C1 Version we have these problems, that many code lines don’t work anymore and in validations the object instance is nothing.

    Do you or your developer have any idea, how we can solve this problem?

    Thank you,

    Regards

  • Posted 20 August 2023, 8:31 pm EST

    I include you two samples (same).

    One with the old version 4.0.20181.588 and one with the newest 4.6.20232.790.

    If you set a breakpoint to the SelectedItem Property and then click the button you see the difference.

    With the old version the SelectedItem doesn’t changes – with the new version, the SelectedItem is set to “Nothing”.

    With the old version we have many code lines in our software which is solved like this.

    How can we solve this?

    Regards

    C1_tests_new.zipC1_tests_old.zip

  • Posted 21 August 2023, 9:40 pm EST

    Hi Patrick,

    Thanks for providing the sample application.

    In the attached sample, you are updating the DataSource of the C1ComboBox on button click. As per the design behavior of C1ComboBox, it displays the text corresponding to its SelectedItem. Since the new ItemsSource collection may or may not contain the previously selected item, hence the SelectedItem property becomes null on updating the ItemsSource of the C1ComboBox. Hence, the behavior shown by the latest version 4.6.20232.790 seems to be valid to us.

    However, in your particular use-case scenario, we would suggest you a workaround to save the SelectedIndex of the C1ComboBox before updating the ItemsSource and set the saved index as the SelectedIndex, after the ItemsSource has been updated.

    Please refer to the attached sample for full implementation. See New_Mod.zip

    Thanks & Regards,

    Aastha

  • Posted 22 August 2023, 8:30 pm EST

    ok.

    But how can I do this, in our solution?

    I have an own class “ComboBox” which inherits the C1ComboBox.

    Which event I will use?

    Regards

  • Posted 24 August 2023, 1:17 am EST

    Hi Patrick,

    The application sample you shared initially used the C1ComboBox control directly. However, considering that your implementation involves a custom class inherited from C1ComboBox, please note that its behavior should remain consistent with C1ComboBox unless you’ve made specific changes by overriding properties, methods, or events.

    Regarding the SelectedIndex property of your custom ComboBox control, if it’s functioning according to the default behavior, it should return the selected item’s index. To better understand your situation, could you please provide a sample that shows the implementation of your custom C1ComboBox control?

    This would better help us in addressing the issues that you’re encountering. Thank you for your cooperation.

    Best Regards,

    Aastha

  • Posted 27 August 2023, 8:45 pm EST

    Hi,

    I can’t provide you our whole solution. But it is like the same sample I already sent you. Only we make an own class ComboBox inherits it from C1ComboBox and use them. And the problem with the selectedindex should handle the combobox class and not in code behind.

    You know what I mean?

    Regards

  • Posted 28 August 2023, 8:41 pm EST - Updated 28 August 2023, 8:47 pm EST

    Hi Patrick,

    Thanks for explaining your use-case scenario.

    As we have already mentioned, the behavior shown by the 4.0.20181.588 version control does not seem to be valid to us. Our suggested workaround for version 4.6.20232.790 can only be implemented using code-behind, as it’s not the default behavior of the newer version.

    Please consider the following scenario that shows the problem with the older version control behavior. The image below shows the updates in the new ItemsSource so that we can analyze the difference better:

    According to your project implementation, clicking the export button sets a new ItemsSource to the C1ComboBox control. When we click the export button, in version 4.0.20181.588, the control retains the selected item and selected value properties from the original ItemsSource. This ends up setting the Text property of the C1ComboBox according to the Selected Item value. Since the displayed Text isn’t part of the new ItemsSource, this behavior is incorrect. On the other hand, version 4.6.20232.790 of C1ComboBox behaves as intended, where it nullifies the selected item and value, showing an empty string as its Text.

    Please refer to the attached image file for the same:

    So, unfortunately, the desired behavior can’t be achieved without code-behind in the latest version of the control.

    Thanks & Regards,

    Aastha

  • Posted 30 August 2023, 5:20 pm EST

    Hello,

    so that means I can’t work with ItemsChanged Event or any other event direct on the combobox?

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels