为什么单击文本框会导致 AutoScroll 面板滚动回顶部?

Why does clicking in a text box cause an AutoScroll panel to scroll back to the top?(为什么单击文本框会导致 AutoScroll 面板滚动回顶部?)

本文介绍了为什么单击文本框会导致 AutoScroll 面板滚动回顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C# 应用程序中完成注册表单,我注意到如果我启用 AutoScroll 然后在滚动下方有一个文本框并单击它,它会一直跳回顶部.有没有办法用一些代码来解决这个问题,或者它是一种礼仪?

Finishing up a register form in a C# application and I noticed with the panel if I enable AutoScroll and then have a textbox that is below the scroll and click on it it jumps all the way back up to the top. Is there a way to fix this with some code or is it a propriety?

我很难用语言来解释它,所以这里有一个简短的视频来展示这种行为.

It's a little difficult for me to explain it in words, so here's a short video that shows the behavior.

推荐答案

我也遇到了同样的问题.我在面板中使用以下代码修复了它:

I have had the same problem. I fixed it with this code in my panel:

protected override Point ScrollToControl(Control activeControl)
{
    return this.AutoScrollPosition;
}

这篇关于为什么单击文本框会导致 AutoScroll 面板滚动回顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:为什么单击文本框会导致 AutoScroll 面板滚动回顶部?