C#textBox自动换行

Dazelongfu 2014-09-13 03:13:08
一个连续的textbox框,形如:


其中每个格子对应一个textbox,有一个事件是前面一格输入一格数字,然后光标自动移到后面一个格子,请问怎么实现?
...全文
512 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dazelongfu 2014-09-17
  • 打赏
  • 举报
回复
搞Java的开发C# 第一次听说无符号数据类型,真的尼玛够郁闷,调了一下午。
threenewbee 2014-09-14
  • 打赏
  • 举报
回复
设置下TabIndex 然后再在文本框的KeyPress里面写SendKeys.Send("{tab}");
Dazelongfu 2014-09-14
  • 打赏
  • 举报
回复
已经找到解决方案,在keypress方法中写入 if (e.KeyChar == 0x08) return; else if ((e.KeyChar < 0x30) || (e.KeyChar > 0x39)) e.KeyChar = (char)0; else { //this.textBox1.Text = e.KeyChar.ToString(); this.textBox1.Select(0, textBox2.Text.Length); /this.ActiveControl = this.textBox2; }
Dazelongfu 2014-09-14
  • 打赏
  • 举报
回复
可以在textBox_keyPress里面定义吗,还是要分别写一个keyPress和textChanged?
qpp_2575406355 2014-09-14
  • 打赏
  • 举报
回复
点击回车键自动换行 private void btn_OK_Click(object sender, EventArgs e) { txt_Change.Location = new Point(0, 0);//设置文本框位置 txt_Change.Multiline = true;//设置文本框显示多行 txt_Change.Width = //设置文本框宽度 this.Width; txt_Change.Height = //设置文本框高度 ClientRectangle.Height - btn_OK.Height-15; }//希望此事件对你有帮助改写即可
我叫小菜菜 2014-09-14
  • 打赏
  • 举报
回复
引用 1 楼 thoughter 的回复:
private void textBox1_TextChanged(object sender, EventArgs e)
 {
    if(textBox1.Text.trim().Length==N)
      textBox2.Focus();
 }
lz要实现的应该是类似输入密钥时自动分割的功能,前面的输入达到指定数值的字符后,焦点自动落在下一个TAB控件。 原理差不多,简单的话,可以类似上面,先判断字符数目,再聚焦下一个TextBox。但这样代码会出现重复(每个TextBox都要写。。) 至于上面的SelectNextControl,没试过
abc2363789187 2014-09-14
  • 打赏
  • 举报
回复

private void textBox1_TextChanged(object sender, EventArgs e)
 {
    Control ctl;
    ctl = (Control)sender;
    ctl.SelectNextControl(ActiveControl, true, true, true, true);
 }
abc2363789187 2014-09-14
  • 打赏
  • 举报
回复
    Control ctl;
    ctl = (Control)sender;
    ctl.SelectNextControl(ActiveControl, true, true, true, true);
这样行不行?
KJ_Wang 2014-09-14
  • 打赏
  • 举报
回复
二楼没问题答案基本可以实现,关键是你要怎么样的结果
thoughter 2014-09-13
  • 打赏
  • 举报
回复
或者类似

       ((TextBox)sender).Parent.SelectNextControl(ActiveControl, true, true, true, true);
thoughter 2014-09-13
  • 打赏
  • 举报
回复
private void textBox1_TextChanged(object sender, EventArgs e)
 {
      textBox2.Focus();
 }

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧