简体   繁体   English

在焦点位于文本框(在面板中)的同时,在自定义编辑器中滚动@ C#

[英]Scroll in custom editor while having focus in textbox (in a panel) @C#

following situation: 以下情况:

Custom Editor Control (with scrollbars) and a search function in a panel (textbox in panel). 自定义编辑器控件(带有滚动条)和面板中的搜索功能(面板中的文本框)。 When having the focus on the textbox/panel it should be scrollable. 当重点放在文本框/面板上时,它应该是可滚动的。

I already tried using override Scroll methodes but mostly the event isn't triggerd. 我已经尝试使用重写Scroll方法,但是大多数情况下不会触发该事件。 There isn't even an event for scrolling in WinForms textboxes so i have no idea on how to catch it. 甚至没有在WinForms文本框中滚动的事件,因此我不知道如何捕获它。

Any ideas / WinAPI hooks? 任何想法/ WinAPI挂钩? Thanks 谢谢

How do you want to scroll? 怎么要滚动? By pressing PgUp and PgDn ? 通过按PgUpPgDn Catch the keys and do the scrolling yourself. 抓住按键并自己滚动。 If not, please explain exactly what user interaction(s) should cause the scrolling! 如果不是,请确切说明什么用户互动会导致滚动!

private void yourSearchTextBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.PageDown) scrollPgDn();
    if (e.KeyCode == Keys.PageUp) scrollPgUp();
    //..
}

Your scroll functions would either call custom editor methods or use some logic to do a reasonable scroll. 您的滚动功能将调用自定义编辑器方法,或使用某些逻辑来进行合理的滚动。 You would set the focus on the editor before and set it back to your search textbox after the scrolling. 您应该先将焦点放在编辑器上,然后在滚动后将其重新设置到搜索文本框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM