如何在第三行诅咒时留下表格富文本框 [英] How to Leave Form Rich Text Box When Curser At Line Three

查看:68
本文介绍了如何在第三行诅咒时留下表格富文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望从富文本框中聚焦另一个对象当它到达第三行时按

输入密钥

例如,

.........按Enter键

.........按Enter键

.........按Enter键(在这一点上)

专注于另一个对象,如Combobox或文本框



如何做到这一点......?

谢谢

I Want To Focus To Another Object From Rich Text Box When It Reach The Third Line By Pressing
Enter Key
Eg,
......... Press Enter
......... Press Enter
......... Press Enter (At This Point)
Focus To Another Object like Combobox Or Text Box

How To Do This..?
Thanks

推荐答案

您可以在<$ c上挂钩 PreviewKeyDownEvent $ c> RichTextBox 然后如果按下的键是 Enter 并且 RichTextBox 有三行,则关注下一个控件;



You can hook into the PreviewKeyDownEvent on your RichTextBox and then focus the next control if the pressed key is Enter and the RichTextBox has three lines;

using System.Linq;
using System.Windows.Forms;

namespace WindowsFormsApplication1 {

    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void richTextBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) {

            if (e.KeyCode == Keys.Enter && richTextBox1.Lines.Count() == 3)
            {
                button1.Focus();
            }
        }
    }
}





希望这有帮助,

Fredrik



Hope this helps,
Fredrik


这篇关于如何在第三行诅咒时留下表格富文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆