如何以编程方式滚动面板? [英] How to programmatically scroll a panel?

查看:66
本文介绍了如何以编程方式滚动面板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以用什么方法以编程方式滚动面板?


有ScrollControlIntoView()但我没有控制滚动

进入视野。我只想让面板向上滚动100个像素。


设置AutoScrollPosition似乎也不起作用。设置的值不值得尊重,并且显然已被框架修改。


顺便说一句,我想要实现的是看到的行为在

记事本(和其他Windows应用程序)中,按住鼠标按钮

并将鼠标拖到窗口下方,内容保持滚动
$ b按住鼠标按钮时向上$ b。我正在使用计时器来实现这个
。在计时器事件处理程序中,我想以编程方式滚动

面板。

What method can I call to programmatically scroll a panel?

There is ScrollControlIntoView() but I don''t have a control to scroll
into view. I just want the panel to scroll up by 100 pixels.

Setting AutoScrollPosition doesn''t seem to work either. The values I
set are not honored, and are apparently modified by the framework.

By the way, what I am trying to implement is the behavior seen in
Notepad (and other Windows apps) where you hold the mouse button down
and drag the mouse below the window, and the contents keep scrolling
up while the mouse button is held down. I am using a timer to achieve
this. In the timer event handler, I want to programmatically scroll
the panel up.

推荐答案

打开伤口,


您可以尝试通过调用SendMessage API函数将WM_VSCROLL消息发送到窗口(假设

滚动条是标准滚动条)

through P / Invoke图层。


此外,您可以随时设置DisplayRectangle属性,

将控件上的视图移动100像素,如下所示:


//面板是mobjPanel。

mobjPanel.DisplayRectangle = mobjPanel.DisplayRectangle.Offset(0,100);


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


Open Wound <运算*********** @ aol.com>在消息中写道

新闻:e3 ************************** @ posting.google.c om ...
Open Wound,

You could try sending the WM_VSCROLL message to the window (assuming the
scrollbars are standard scrollbars) by calling the SendMessage API function
through the P/Invoke layer.

Additionally, you could always set the DisplayRectangle propery,
shifting the view on the control by 100 pixels, like so:

// The panel is mobjPanel.
mobjPanel.DisplayRectangle = mobjPanel.DisplayRectangle.Offset(0, 100);

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Open Wound" <op***********@aol.com> wrote in message
news:e3**************************@posting.google.c om...
我可以调用哪种方法以编程方式滚动面板?

有ScrollControlIntoView()但我没有控件可以滚动到视图中。我只想让面板向上滚动100个像素。

设置AutoScrollPosition似乎也不起作用。我设置的值不受尊重,并且显然已被框架修改。

顺便说一下,我想要实现的是在
记事本中看到的行为(和其他Windows应用程序),您按住鼠标按钮
并将鼠标拖动到窗口下方,并在按住鼠标按钮时内容继续向上滚动。我正在使用计时器实现这个。在计时器事件处理程序中,我想以编程方式滚动面板。
What method can I call to programmatically scroll a panel?

There is ScrollControlIntoView() but I don''t have a control to scroll
into view. I just want the panel to scroll up by 100 pixels.

Setting AutoScrollPosition doesn''t seem to work either. The values I
set are not honored, and are apparently modified by the framework.

By the way, what I am trying to implement is the behavior seen in
Notepad (and other Windows apps) where you hold the mouse button down
and drag the mouse below the window, and the contents keep scrolling
up while the mouse button is held down. I am using a timer to achieve
this. In the timer event handler, I want to programmatically scroll
the panel up.



您不能分配DisplayRectangle,因为它是只读的。


-

cody


[免费软件,游戏和幽默]
www.deutronium.de.vu || www.deutronium.tk


" Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com> schrieb

im Newsbeitrag新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...
You cannot assign DisplayRectangle because it is readonly.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:%2****************@TK2MSFTNGP10.phx.gbl...
Open Wound ,

您可以尝试通过P / Invoke层调用SendMessage API
函数,将WM_VSCROLL消息发送到窗口(假设
滚动条是标准滚动条)。另外,你可以随时设置DisplayRectangle属性,将控件上的视图移动100像素,如下所示:

//面板是mobjPanel。 /> mobjPanel.DisplayRectangle = mobjPanel.DisplayRectangle.Offset(0,100);

希望这会有所帮助。

-
- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com

;打开伤口 <运算*********** @ aol.com>在消息中写道
新闻:e3 ************************** @ posting.google.c om ...
Open Wound,

You could try sending the WM_VSCROLL message to the window (assuming the scrollbars are standard scrollbars) by calling the SendMessage API function through the P/Invoke layer.

Additionally, you could always set the DisplayRectangle propery,
shifting the view on the control by 100 pixels, like so:

// The panel is mobjPanel.
mobjPanel.DisplayRectangle = mobjPanel.DisplayRectangle.Offset(0, 100);

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Open Wound" <op***********@aol.com> wrote in message
news:e3**************************@posting.google.c om...
我可以调用哪种方法以编程方式滚动面板?

有ScrollControlIntoView()但我没有控件可以滚动进入视图。我只想让面板向上滚动100个像素。

设置AutoScrollPosition似乎也不起作用。我设置的值不受尊重,并且显然已被框架修改。

顺便说一下,我想要实现的是在
记事本中看到的行为(和其他Windows应用程序),您按住鼠标按钮
并将鼠标拖动到窗口下方,并在按住鼠标按钮时内容继续向上滚动。我正在使用计时器实现这个。在计时器事件处理程序中,我想以编程方式滚动面板。
What method can I call to programmatically scroll a panel?

There is ScrollControlIntoView() but I don''t have a control to scroll
into view. I just want the panel to scroll up by 100 pixels.

Setting AutoScrollPosition doesn''t seem to work either. The values I
set are not honored, and are apparently modified by the framework.

By the way, what I am trying to implement is the behavior seen in
Notepad (and other Windows apps) where you hold the mouse button down
and drag the mouse below the window, and the contents keep scrolling
up while the mouse button is held down. I am using a timer to achieve
this. In the timer event handler, I want to programmatically scroll
the panel up.




我得到了相同的错误也是。也是C#的新手,通过P / Invoke层调用SendMessage API

函数转换为使用floober通过blavar

获得proobser...请为我们的新手发布代码示例,以便我们知道

这意味着什么!

与此同时,我发现这也会滚动一个面板:


myPanel.AutoScrollPosition = new Point(0,1152);


更改点(0,y),以便y是您想要在面板中向上滚动的距离。


-Joey
I got the same error too. Also new to C#, "calling the SendMessage API
function through the P/Invoke layer" translates to "use floober via blavar
to get proobser"... please post code example for us newbies so we know what
this means!
In the meantime, I found that this will scroll a panel too:

myPanel.AutoScrollPosition = new Point(0,1152);

Change Point(0,y) so that y is how far you want to scroll up in panel.

-Joey


这篇关于如何以编程方式滚动面板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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