سؤال

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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

Its not a good idea to modify the desginer.cs file. Attach the event in the form designer or you can attach the event in the code behind (form.cs). It is probably disappearing if you are loading the form in the designer and you are getting the message to ignore changes and reload design.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top