Is there any way to set an event handler without doing it manually in the classname.designer.cs file other than double clicking the UI element?
在classname.designer.cs文件中自动设置事件处理程序。
原标题:
最佳回答
Click on the lightning bolt icon in the Properties window. Double-click the event you want to implement.
问题回答
If I follow your question correctly, you can just do it in your code-behind like this:
myButton.Click += myHandler;
Or you could use an anonymous delegate:
myButton.Click += delegate
{
MessageBox.Show("Clicked!");
};
当然。在初始化过程中某个地方(如窗体的构造函数中),使用myControl.Event += new EventHandler(SomeHandlerMethodInYourClass)
。
相关问题
热门标签
- winforms
- combobox
- fogbugz
- java
- date
- internationalization
- asp.net
- iis
- url-rewriting
- urlrewriter
- c#
- enums
- ocaml
- haxe
- algorithm
- string
- viewstate
- .net
- c++
- c
- symbol-table
- mysql
- database
- postgresql
- licensing
- migration
- vb.net
- vb6
- declaration
- vb6-migration
- python
- psycopg2
- backup
- vmware
- virtualization
- gnu-screen
- authentication
- desktop
- excel
- xll
- cultureinfo
- regioninfo
- oracle
- client
- session
- download
- html
- virtual
- constructor
- scenarios
- perl
- full-text-search
- javascript
- ajax
- testing
- oop
- inheritance
- vim
- encapsulation
- information-hiding