单击并拖动一个富文本框中的文本 [英] Click and drag text in a rich text box

查看:89
本文介绍了单击并拖动一个富文本框中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我只是想知道是否有人知道在富文本框中选择多行文本时按住shift键和下移键等会触发什么消息.或单击并向上/向下拖动以选择多行.

我有一个自定义滚动条,但是找不到WinPoc()中应该显示的消息? =/

感谢George

解决方案

您要实现什么功能,以及为什么要使用自定义滚动条?

SelectionChanged是一个显而易见的事件,将始终被触发.

我建议您使用RichTextBox创建一个测试项目,''richTextBox1,将其Font设置为大字体,使RTF控件的尺寸较小,以便自动换行,并实现以下事件: lang ="cs"> 私有 void richTextBox1_SelectionChanged( object 发​​送者,EventArgs e) { Console.WriteLine(" ); } 私有 无效 richTextBox1_Resize(对象发​​件人,EventArgs e) { Console.WriteLine(" ); } 私有 无效 richTextBox1_ClientSizeChanged(对象发​​件人,EventArgs e) { Console.WriteLine(" ); } 私有 无效 richTextBox1_VScroll(对象发​​件人,EventArgs e) { Console.WriteLine(" ); }

实验,并使用您描述的各种选择类型观察写入控制台的内容.

也许,首先尝试键入直到RTF控件自动滚动,因为您已经超出了它的范围:检查仅由该事件触发的事件.

当您通过单击拖动使RichTextBox的可见区域发生更改以及您自己移动Vertical ScrollBar时,都应特别注意VScroll EventHandler的执行方式.

考虑一下您观察到ClientSizeChanged和Resize EventHandlers被调用的方式的含义.


Hi All,

I am just wondering if anyone knows what message is fired when shift and down etc is held in a rich text box to select multiple lines of text. Or click and drag up/down to select multiple lines.

I Have a custom scroll bar hocked up but just cant find what message i should be trying to find if it is something in WinPoc() ? =/

Thanks George

解决方案

What functionality are you trying to implement, and why are you using a custom scroll bar ?

SelectionChanged is an obvious event that will be fired, always.

I suggest you create a test project with a RichTextBox, ''richTextBox1, set its Font to a large size font, make the RTF control small in size, so word-wrap will be triggered easily, and the implement the following Events:

private void richTextBox1_SelectionChanged(object sender, EventArgs e)
{
    Console.WriteLine("sel changed");
}

private void richTextBox1_Resize(object sender, EventArgs e)
{
    Console.WriteLine("resz");
}

private void richTextBox1_ClientSizeChanged(object sender, EventArgs e)
{
    Console.WriteLine("client sz changed");
}

private void richTextBox1_VScroll(object sender, EventArgs e)
{
    Console.WriteLine("vscroll changed");
}

Experiment, and observe what''s written to the Console, using the variety of types of selections you describe.

Perhaps, first try just typing away until the RTF control auto-scrolls because you''ve exceeded its bounds: examine what events are triggered by that alone.

Pay particular attention to how the VScroll EventHandler is executed both when you, by click dragging, cause the visible area of the RichTextBox to change, and when you move the Vertical ScrollBar yourself.

Think about the implications of the ways you''ll observe ClientSizeChanged and Resize EventHandlers being called.


这篇关于单击并拖动一个富文本框中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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