Search code examples
c#winformsinfragistics

The WinForms designer code is changed whenever I add new control


I add a UltraListView Control in my form, which is from Infragistics. And I manually add an event in the designer.cs like below:

this.ultraListView1.ItemSelectionChanged += ultraListView1_ItemSelectionChanged;

It will be called when I change the selected item in UltraListView. And it works very well. But when I add some controls to the form, this line will disappear. So I need to manually add it again and again. How can I fix it?


Solution

  • Working with the Infragistics control is the same way as with all the WinForms controls.

    • Open your dialog in the Designer.
    • Right click on the control will open the following popup menu. Select Properties:

    enter image description here

    • In the Properties window click on the Events button and scroll to find out required event. Then double-click on the required event:

    enter image description here

    The Visual Studio Designer will add the selected event handler and open it code for editing.