|
I've created various custom controls that inherit from the regular windows controls (textbox, combobox, datagrid), but provide a little extra functionality. I have added my custom controls to the toolbox so when I am in the designer, I can just drag and drop them onto my forms. The problem is when I do add them to my form, the designer generates the code for them (in the InitializeComponent Sub) without adding the "WithEvents" clause in the control declaration statement (Friend CustomControl1 as CustomControl). So I have to go into the code and add the clause myself. Then I create a Sub to handle the various events of the control. The next time I change anything on the form in the designer, the InitializeComponent sub is regenerated, thus, I lose my WithEvents clause again and the Handles clause is dropped from my Sub. My question is how do you force the WithEvents clause to generate when the designer writes the code for your custom controls?
Thanks, --Patrick |