[NET6] Design time behavior of C1SplitButton items

Posted by: wknauf on 25 October 2022, 8:09 am EST

    • Post Options:
    • Link

    Posted 25 October 2022, 8:09 am EST - Updated 25 October 2022, 8:14 am EST

    Hi C1,

    it seems there was a change in the ways that the C1SplitButton dropdown items are handled in designer.

    See attached sample - it contains a .NET 4.8 project and a .NET 6 project:

    SplitButtonTest.zip

    In .NET 4.8, there were member variables for each dropdown item, and in the designer, they had a name (which is the member variable name):

        private C1.Win.C1Input.DropDownItem dropDownItem1;

    I copied the sample form to the .NET 6 project and converted to .NET6:

        private C1.Win.Input.SplitButtonItem dropDownItem1;

    Now open the .NET6 form in designer and edit the items:

    You will see that the items don’t have a property “Name”:

    Now make any change to the form, e.g. change the location of the C1SplitButton. Save the form.

    The SplitButtonItem variables were converted to local variables in “InitializeComponent”. And unfortunately, the class member variables are still there, but unused:

        private void InitializeComponent()
        {
          C1.Win.Input.SplitButtonItem splitButtonItem1 = new C1.Win.Input.SplitButtonItem();
          C1.Win.Input.SplitButtonItem splitButtonItem2 = new C1.Win.Input.SplitButtonItem();
          this.c1SplitButton1 = new C1.Win.Input.C1SplitButton();

    (to revert this, copy the code from “Form1_Original”)

    Is this intended behavior? Or a bug? Or a limitation of the .NET6 WinForms designer?

    If possible bring back the code that created member variables for the items. The current behavior might break existing forms by simply opening them in designer.

    Best regards

    Wolfgang

  • Posted 25 October 2022, 8:32 am EST

    And to explain why this causes a problem: our code handles the C1SplitButton “ItemClicked” handler and checks which item is clicked:

        private void splitButton_ItemClicked(object sender, ItemClickedEventArgs e)
        {
          if (e.ClickedItem == this.dropDownItemOne)
          {
            //Do something
          }
          else if (e.ClickedItem == this.dropDownItemTwo)
          {
            //Do something else
          }
          else
          {
            //Error
          }
        }

    This will no longer work, as the variables are not assigned any more.

    The only workaround would be to assign a “Tag” to the items. But the previous approach is better I think.

  • Posted 27 October 2022, 12:38 am EST

    Hi Wolfgang,

    Thank you for sharing the sample project and details. We could see the behaviors you mentioned on our end. We have shared all your observations with the development team to get their insights on it and will let you know as soon as we have an update from them.

    [Internal Tracking ID: C1WIN-28467]

    Best Regards,

    Kartik

  • Posted 7 November 2022, 3:27 am EST

    Hi Wolfgang,

    The reason for the change in behavior is that the .NET Framework 4.5.2/4.8 version uses the “System.ComponentModel.Component” as the base class for the Split button item, but the .NET 6 version doesn’t use this base class.

    While discussing your case, the development team has considered updating the .NET 6 C1SplitButton to revert the current behavior back to the old behavior, as this change might impact the customers that are/will be upgrading from .NET Framework to .NET 6.

    We will get back to you with updates as soon as possible.

    Best Regards,

    Kartik

  • Posted 7 November 2022, 4:01 am EST

    Thanks!

    Wolfgang

  • Posted 6 January 2023, 8:33 am EST

    Hi Wolfgang,

    We are happy to let you know that this issue has been fixed in the latest 2022v3 (588) Hotfix release.

    Kind Regards,

    Kartik

  • Posted 6 January 2023, 9:25 am EST

    Great, many thanks! I can confirm that my sample works.

    Wolfgang

Need extra support?

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

Learn More

Forum Channels