Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio keeps deleting code in form.designers

I'm making a winform application. I'm trying to add a keydown event to a combo box so I prepared the event implementation and then I added inside the form.designers document the line:

this.cmboxSearchPath.KeyDown += cmboxSearchPath_KeyDown;

for some reason this line always get deleted from the document.. do you know why and how can I stop it from being deleted?

like image 479
Yonatan Nir Avatar asked Oct 25 '25 15:10

Yonatan Nir


1 Answers

for some reason this line always get deleted from the document.. do you know why and how can I stop it from being deleted?

Don't put it in the designer generated code. You can include this in your constructor after the InitializeComponent() call, or allow the designer to generate this for you by wiring up the event via the designer itself.

like image 134
Reed Copsey Avatar answered Oct 27 '25 03:10

Reed Copsey