| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 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 | 
													Tags
													
											
												
												- MSSQL
- MEAN Stack
- 파이썬
- 자본주의
- pymssql
- tensorflow
- sql developer
- vscode
- 텐서플로우
- 딥러닝
- 티스토리 초대장
- PYTHON MSSQL
- matplot
- 장고
- Serial
- scrapy
- MSSQL PYTHON
- MX Component
- rs485
- windows10
- Python
- django
- 오라클
- c#
- 윈도우10
- 크롤링
- Visual Studio Code
- M2M
- oracle
- rs422
													Archives
													
											
												
												- Today
- Total
안까먹을라고 쓰는 블로그
[C#] InputBox 구현 본문
반응형
    
    
    
  ■ 구현부분
| 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 32 33 34 35 | public DialogResult InputBox(string title, string promptText, ref string value) {     Form form = new Form();     Label label = new Label();     TextBox textBox = new TextBox();     Button buttonOk = new Button();     Button buttonCancel = new Button();     form.Text = title;     label.Text = promptText;     textBox.Text = value;     buttonOk.Text = "OK";     buttonCancel.Text = "Cancel";     buttonOk.DialogResult = DialogResult.OK;     buttonCancel.DialogResult = DialogResult.Cancel;     label.SetBounds(9, 20, 372, 13);     textBox.SetBounds(12, 36, 372, 20);     buttonOk.SetBounds(228, 72, 75, 23);     buttonCancel.SetBounds(309, 72, 75, 23);     label.AutoSize = true;     textBox.Anchor = textBox.Anchor | AnchorStyles.Right;     buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;     buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;     form.ClientSize = new Size(396, 107);     form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });     form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);     form.FormBorderStyle = FormBorderStyle.FixedDialog;     form.StartPosition = FormStartPosition.CenterScreen;     form.MinimizeBox = false;     form.MaximizeBox = false;     form.AcceptButton = buttonOk;     form.CancelButton = buttonCancel;     DialogResult dialogResult = form.ShowDialog();     value = textBox.Text;     return dialogResult; } | cs | 
■ 사용 방법
| 1 2 3 4 5 | string value = "info@example.com"; if (CM.InputBox("Enter your email", "Email :", ref value) == DialogResult.OK) {     MessageBox.Show(value); } | cs | 
■ 추가 - 사용방법
| 1 2 3 4 5 6 7 8 9 | private void frmMain_FormClosing(object sender, FormClosingEventArgs e) {     string value = "";     if (CM.InputBox("Enter your Password", "PassWord", ref value) == DialogResult.OK)     {         if (value == GV.ApplicationPWD) { }         else e.Cancel = true;     } } | cs | 
[자료출처] http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=18&MAEULNO=8&no=1944&page=3
반응형
    
    
    
  'Language > C#' 카테고리의 다른 글
| .NET FrameWork No Down Version (0) | 2013.11.07 | 
|---|---|
| [C#] 프로그램에서 Enter, Esc키를 눌렀을때 실행될 버튼_Clink 이벤트 연결하기 (0) | 2013.10.08 | 
| [C#] 실행중인 Child Form 개수 설정 (0) | 2013.06.27 | 
| [C#] NameSpace (0) | 2013.06.10 | 
| [C#] Service Project 만들기 (0) | 2013.05.10 | 
								  Comments
								
							
						
					
                    
                
					
					
					
					
					
					
				