96. 마스크(Mask) / 리치(Rich) / 읽기전용(ReadOnly) 텍스트박스(TextBox)
==> Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace MyWinForms
{
static class Program
{
/// <summary>
/// 해당 응용 프로그램의 주 진입점입니다.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}
==============================================================================================
==> MainForm.cs
private void miTextBox_Click(object sender, EventArgs e)
{
MyWinForms.Controls.FrmTextBox ftb = new MyWinForms.Controls.FrmTextBox();
ftb.MdiParent = this;
ftb.Show();
}
==============================================================================================
==> FrmTextBox.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyWinForms.Controls
{
public partial class FrmTextBox : Form
{
public FrmTextBox()
{
InitializeComponent();
}
private void btnOK_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.Append("싱글라인 : " + txtSingleLine.Text);
sb.AppendFormat("멀티라인 : {0}", txtMultiLine.Text);
sb.Append(String.Format("패스워드 : {0}", txtPassword.Text));
sb.Append("마스크 : " + txtMaskedText.Text);
sb.AppendFormat("리치 : {0}", txtRichTextBox.Text);
MessageBox.Show(sb.ToString());
}
}
}
< 실행결과 >
/*
읽기전용(ReadOnly) 텍스트박스는 텍스트박스와는 달리 텍스트박스에 이미 텍스트가 입력되어 있으며, 레이블에 쓰여져 있는 텍스트와는 달리 긁어서 복사할 수 있다.
*/