数字转换成字符问题? 很简单啊用SWITCH或者IF都可以啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 其实就是响应一下TextBox的KeyPress事件:1.InitializeComponent中添加:this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);2.添加事件处理函数:private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e){ if( !e.Handled ) { char keyChar = e.KeyChar; int idx = textBox1.SelectionStart; switch( keyChar ) { case '0': { textBox1.Text = textBox1.Text.Insert( idx, "零" ); textBox1.SelectionStart = textBox1.Text.Length; e.Handled = true;break; } case '1': { textBox1.Text = textBox1.Text.Insert( idx, "壹" ); textBox1.SelectionStart = textBox1.Text.Length; e.Handled = true;break; } case '2': { textBox1.Text = textBox1.Text.Insert( idx, "贰" ); textBox1.SelectionStart = textBox1.Text.Length; e.Handled = true;break; } case '3': { textBox1.Text = textBox1.Text.Insert( idx, "叁" ); textBox1.SelectionStart = textBox1.Text.Length; e.Handled = true;break; } case '4': { textBox1.Text = textBox1.Text.Insert( idx, "肆" ); textBox1.SelectionStart = textBox1.Text.Length; e.Handled = true;break; } case '5': { textBox1.Text = textBox1.Text.Insert( idx, "伍" ); textBox1.SelectionStart = textBox1.Text.Length; e.Handled = true;break; } case '6': { textBox1.Text = textBox1.Text.Insert( idx, "陆" ); textBox1.SelectionStart = textBox1.Text.Length; e.Handled = true;break; } case '7': { textBox1.Text = textBox1.Text.Insert( idx, "柒" ); textBox1.SelectionStart = textBox1.Text.Length; e.Handled = true;break; } case '8': { textBox1.Text = textBox1.Text.Insert( idx, "捌" ); textBox1.SelectionStart = textBox1.Text.Length; e.Handled = true;break; } case '9': { textBox1.Text = textBox1.Text.Insert( idx, "玖" ); textBox1.SelectionStart = textBox1.Text.Length; e.Handled = true;break; } } }} 太麻烦啦string[] a = new string[]{"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};char keyChar = e.KeyChar;int n = Int32.Parse(new string(keyChar));textBox1.Text = a[n]; 没太看清题,答的与你的要求有出入,应该这样,得到keyChar 后,先判断是否是'0'-'9'(可以根据ascii码来确定) 各位都来看看 找高手,判断listview中的范围 今天真正觉得360安全卫士牛逼了 C#读文本文件,中文字符结果均为��,求教。 如何从一串GPS信息里提取需要的东西?(高分送上~~~~高手请进) 请问大家VS.NET里面的配置管理器不能用怎么解决? 如何伪造IP地址?高分求解。 关于outlook2003的插件 C#中数据库的保存问题,在线等待,急! 谁知道怎么用C#设计类似QQ的程序? 在.net环境下,用c#写代码,怎么样能把java文件导入到c#中 大家帮我看看,为什么我这个存储过程在查询分析器中可以得到正确结果,在C#中却得不到正确结果
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);2.添加事件处理函数:
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if( !e.Handled )
{
char keyChar = e.KeyChar;
int idx = textBox1.SelectionStart; switch( keyChar )
{
case '0':
{
textBox1.Text = textBox1.Text.Insert( idx, "零" );
textBox1.SelectionStart = textBox1.Text.Length;
e.Handled = true;break;
}
case '1':
{
textBox1.Text = textBox1.Text.Insert( idx, "壹" );
textBox1.SelectionStart = textBox1.Text.Length;
e.Handled = true;break;
}
case '2':
{
textBox1.Text = textBox1.Text.Insert( idx, "贰" );
textBox1.SelectionStart = textBox1.Text.Length;
e.Handled = true;break;
}
case '3':
{
textBox1.Text = textBox1.Text.Insert( idx, "叁" );
textBox1.SelectionStart = textBox1.Text.Length;
e.Handled = true;break;
}
case '4':
{
textBox1.Text = textBox1.Text.Insert( idx, "肆" );
textBox1.SelectionStart = textBox1.Text.Length;
e.Handled = true;break;
}
case '5':
{
textBox1.Text = textBox1.Text.Insert( idx, "伍" );
textBox1.SelectionStart = textBox1.Text.Length;
e.Handled = true;break;
}
case '6':
{
textBox1.Text = textBox1.Text.Insert( idx, "陆" );
textBox1.SelectionStart = textBox1.Text.Length;
e.Handled = true;break;
}
case '7':
{
textBox1.Text = textBox1.Text.Insert( idx, "柒" );
textBox1.SelectionStart = textBox1.Text.Length;
e.Handled = true;break;
}
case '8':
{
textBox1.Text = textBox1.Text.Insert( idx, "捌" );
textBox1.SelectionStart = textBox1.Text.Length;
e.Handled = true;break;
}
case '9':
{
textBox1.Text = textBox1.Text.Insert( idx, "玖" );
textBox1.SelectionStart = textBox1.Text.Length;
e.Handled = true;break;
} }
}
}
string[] a = new string[]{"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};char keyChar = e.KeyChar;
int n = Int32.Parse(new string(keyChar));
textBox1.Text = a[n];