SMS TextLength 비교
SMS 입력받고 데이타 길이 체크하는 처리부분.
public partial class Form1 : Form
{
bool char_ASCIICODE = false;
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
int length = Encoding.Default.GetBytes(this.textBox1.Text).Length;
if (length > 80)
{
this.textBox1.Text = this.textBox1.Text.Substring(0, this.textBox1.TextLength - (char_ASCIICODE ? 1 : 2));
char_ASCIICODE = false;
this.textBox1.Select(this.textBox1.TextLength, 0);
return;
}
length = Encoding.Default.GetBytes(this.textBox1.Text).Length;
this.label1.Text = string.Format("{0}/80", length);
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar < 256)
char_ASCIICODE = true;
else
char_ASCIICODE = true;
}
}
그리 어려운 코드가 아니라 주석도 없다!
'# 2) .Net ( Vs 2005 ) > WinForm' 카테고리의 다른 글
폼간 데이타 전달 (0) | 2009.05.02 |
---|---|
그리드뷰 컨트롤 (0) | 2009.05.02 |
Excel Export (0) | 2009.05.01 |
판넬 슬라이드 애니메이션 (0) | 2009.05.01 |
데이타베이스 브라우져 ver3 (0) | 2009.05.01 |