EventHandler
How do I use Event Handler
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: Form1.cs
Copy
32 {
33 get
34 {
35 if (defaultInstance == null)
36 {
37 defaultInstance = new Form1();
38 defaultInstance.FormClosed += new FormClosedEventHandler(defaultInstance_FormClosed);
39 }
40
41 return defaultInstance;
42 }
43 }
File name: frmMain.cs
Copy
59 private void InitializeComponent()
60 {
61 this.components = new System.ComponentModel.Container();
62 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
63 this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
64 this.menuItem1 = new System.Windows.Forms.MenuItem();
65 this.FileLoad = new System.Windows.Forms.MenuItem();
66 this.FileSave = new System.Windows.Forms.MenuItem();
67 this.FileExit = new System.Windows.Forms.MenuItem();
68 this.menuItem4 = new System.Windows.Forms.MenuItem();
69 this.FilterGrayScale = new System.Windows.Forms.MenuItem();
70 this.FilterColor = new System.Windows.Forms.MenuItem();
71 this.menuItem3 = new System.Windows.Forms.MenuItem();
72 this.EmbossLaplacian = new System.Windows.Forms.MenuItem();
73 this.EdgeDetectQuick = new System.Windows.Forms.MenuItem();
74 this.SuspendLayout();
75 //
76 // mainMenu1
77 //
78 this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
79 this.menuItem1,
80 this.menuItem4,
81 this.menuItem3});
82 //
83 // menuItem1
84 //
85 this.menuItem1.Index = 0;
86 this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
87 this.FileLoad,
88 this.FileSave,
89 this.FileExit});
90 this.menuItem1.Text = "File";
91 //this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
92 //
93 // FileLoad
94 //
95 this.FileLoad.Index = 0;
96 this.FileLoad.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
97 this.FileLoad.Text = "Mở file";
98 this.FileLoad.Click += new System.EventHandler(this.File_Load);
99 //
100 // FileSave
101 //
102 this.FileSave.Index = 1;
103 this.FileSave.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
104 this.FileSave.Text = "Lưu file";
105 this.FileSave.Click += new System.EventHandler(this.File_Save);
106 //
107 // FileExit
108 //
109 this.FileExit.Index = 2;
110 this.FileExit.Text = "Thoát";
111 this.FileExit.Click += new System.EventHandler(this.File_Exit);
112 //
113 // menuItem4
114 //
115 this.menuItem4.Index = 1;
116 this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
117 this.FilterGrayScale,
118 this.FilterColor});
119 this.menuItem4.Text = "Biến đổi màu";
120 //
121 // FilterGrayScale
122 //
123 this.FilterGrayScale.Index = 0;
124 this.FilterGrayScale.Text = "Xám";
125 this.FilterGrayScale.Click += new System.EventHandler(this.Filter_GrayScale);
126 //
127 // FilterColor
128 //
129 this.FilterColor.Index = 1;
130 this.FilterColor.Text = "Màu";
131 this.FilterColor.Click += new System.EventHandler(this.Filter_Color);
132 //
133 // menuItem3
134 //
135 this.menuItem3.Index = 2;
136 this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
137 this.EmbossLaplacian,
138 this.EdgeDetectQuick});
139 this.menuItem3.Text = "Phát hiện biên";
140 //this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
141 //
142 // EmbossLaplacian
143 //
144 this.EmbossLaplacian.Index = 0;
145 this.EmbossLaplacian.Text = "Laplacian_Emboss";
146 this.EmbossLaplacian.Click += new System.EventHandler(this.OnEmbossLaplacian);
147 //
148 // EdgeDetectQuick
149 //
150 this.EdgeDetectQuick.Index = 1;
151 this.EdgeDetectQuick.Text = "EdgeDetectQuick";
152 this.EdgeDetectQuick.Click += new System.EventHandler(this.OnEdgeDetectQuick);
153 //
154 // frmMain
155 //
156 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
157 this.BackColor = System.Drawing.SystemColors.ControlLightLight;
158 this.BackgroundImage = global::CSharpFilters.Properties.Resources.Daewoo;
159 this.ClientSize = new System.Drawing.Size(349, 237);
160 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
161 this.Menu = this.mainMenu1;
162 this.Name = "frmMain";
163 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
164 this.Text = "Xu ly anh";
165 //this.Load += new System.EventHandler(this.Form1_Load);
166 this.ResumeLayout(false);
167
168 }
File name: notepad1.cs
Copy
487 private void fontKlyeMethod()
488 {
489 // FontDialog fontdialog = new FontDialog() {
490 fontdialog.ShowColor = true;
491 fontdialog.ShowApply = true;
492
493 fontdialog.Apply += new System.EventHandler(fontdialog_apply);
494
495 // };
496 // fontdialog.ShowColor = true;
497
498 DialogResult result = fontdialog.ShowDialog(); //ye dialogresult khudsy agr na likha jay to uper sy copy krlyn
499
500 if (result == DialogResult.OK)
501 {
502 if (mainrichTextBox.SelectionLength > 0)
503 {
504 mainrichTextBox.SelectionFont = fontdialog.Font;
505 mainrichTextBox.SelectionColor = fontdialog.Color;
506 }
507 else
508 {
509 //MessageBox.Show("please select first");
510 }
511 }
512 else
513 {
514
515
516 }
517
518 }
File name: frmEnrollment.cs
Copy
125 void FrmEnrollmentLoad(object sender, EventArgs e)
126 {
127 grabber = new Capture();
128 grabber.QueryFrame();
129 Application.Idle += new EventHandler(FrameGrabber);
130 }
File name: MainForm.cs
Copy
163 private void FrmPrincipal_Load(object sender, EventArgs e)
164 {
165 grabber = new Capture();
166 grabber.QueryFrame();
167 Application.Idle += new EventHandler(FrameGrabber);
168 }
EventHandler 87 lượt xem
Gõ tìm kiếm nhanh...