C# TextBox 대 소문자 변경 하기
C#/Tip :
2010. 11. 3. 17:08
네이버 지식IN에서 질문 중에 TextBox의 글자를 버튼이 클릭되었을때는
대문자로 아닐때는 원래대로 출력되는 방법을 질문 받은적 있습니다.
그래서 답변용으로 작성하고 블로그에도 남겨봅니다.
private bool isUpper = false;
private void button1_Click(object sender, EventArgs e)
{
if (!isUpper)
{
button1.Text = "SHIFT";
}
else if (isUpper)
{
button1.Text = "shift";
}
isUpper = !isUpper;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
string upper = textBox1.Text;
string complete = "";
int num = textBox1.SelectionStart - 1;
if (isUpper)
{
for (int i = 0; i < upper.Length; i++)
{
if (i == num)
{
complete += upper[i].ToString().ToUpper();
}
else
{
complete += upper[i].ToString();
}
}
textBox1.Text = complete;
textBox1.Select(num+1, 0);
}
}
'C# > Tip' 카테고리의 다른 글
| Microsoft .NET Framework 3.5 SP1 & Microsoft .NET Framework 4.0 (25) | 2011.01.24 |
|---|---|
| C# 공유폴더 로그인 하고 접근 하는 법(WNetUseConnection) (3) | 2011.01.10 |
| C# 네트워크(Network) TCP 클라이언트 만들어보기 (0) | 2010.08.14 |
| C# 네트워크(Network) TCP 서버 만들어보기 (0) | 2010.08.14 |
| C# SQLITE API (0) | 2010.08.12 |


