문제

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