티스토리 뷰
using System.Windows.Forms;
namespace DetectUserControlClosing
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
protected override void OnCreateControl()
{
base.OnCreateControl();
this.ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing);
}
private void ParentForm_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult myResult = MessageBox.Show("Would you like the parent form to close?",
"Allow Close?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (myResult == DialogResult.No)
{
e.Cancel = true;
}
}
}
}
namespace DetectUserControlClosing
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
protected override void OnCreateControl()
{
base.OnCreateControl();
this.ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing);
}
private void ParentForm_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult myResult = MessageBox.Show("Would you like the parent form to close?",
"Allow Close?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (myResult == DialogResult.No)
{
e.Cancel = true;
}
}
}
}
'Code > C#' 카테고리의 다른 글
| [C#] Shift Operator (0) | 2010.02.17 |
|---|---|
| [C#] Register/Unregister ActiveX Control (0) | 2009.03.15 |
| [C#] DockPanel Suite Sample (0) | 2009.01.05 |
| [C#] DockPanel Suite Sample (0) | 2009.01.05 |
| [C#] MDI Sample (0) | 2009.01.05 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 유틸리티
- .net framework
- Rollback Rx
- Phalanger
- READYSTATE_COMPLETE
- 애드센스숨기기
- iTextSharp
- WinAutomation
- AdSense숨기기
- registry
- Regular Expressions
- autohotkey
- ScreenHunter
- 애드센스감추기
- windows
- Sample Code
- Service pack
- java
- tagREADYSTATE
- iText
- jre
- AdSense감추기
- download.com
- AxWebBrowser
- Microsoft
- 스크린캡쳐
- c#
- DotNetMagic
- Automation
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
글 보관함
DetectUserControlClosing.zip