- public delegate void 委托名EventHandler(object sender, EventArgs e);
- public partial class 用户控件类名: UserControl
- {
-
-
-
- public event 委托名EventHandler 事件名;
- private int _selectedPosition = 0;
-
-
-
- public int SelectedPosition
- {
- get { return _selectedPosition; }
- set { _selectedPosition = value; }
- }
- private void 控件的某操作_Clicked(object sender, EventArgs e)
- {
-
-
-
- if (事件名 != null)
- 事件名(this,EventArgs.Empty);
- }
- }
- this.ucToothPosition1.OnValueChanged += new ValueChangedEventHandler(ucToothPosition1_OnValueChanged);
- void ucToothPosition1_OnValueChanged(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.OK;
- }