控制窗体外,使用滚动条移动控件 [英] Controls out of form, move controls with scroll bar

查看:95
本文介绍了控制窗体外,使用滚动条移动控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有一个小型的程序,但我需要很多标签,按钮......来穿上。参见图片:http://www.anyfiles.org/2zSM

或查看VLC播放器,它的首选项,选择显示所有命令,在右侧部分,您将看到它填充了许多控件和如果它们中有很多,它会显示滚动条上/下。



- 使这个工作的最佳方法是什么?我希望用户向下滚动并查看所有标签,按钮,文本框,...



WinForm和WPF的最佳方法是什么?



我尝试了什么:



现在我使用了多个标签页面。但我不喜欢这个选项,neider做用户。

I need to have small form for program, but I need a lot of labels, buttons,... to put on. See picture on: http://www.anyfiles.org/2zSM
or see VLC player, it's preferences, select to show all commands and on the right part, you will see it populates many controls and if there's to many of them, it shows scroll bar to go up/down.

- What is the best way to make this working? I would like for user to scroll down and see all labels, buttons, textboxes,...

What is the best way for this for WinForm and for WPF?

What I have tried:

For now I have used multiple tab pages. But I don't like this option, neider do users.

推荐答案

你提到了VLC,但是,VLC广泛使用菜单(屏幕上方除非你选择查看全屏)和上下文菜单。



如果您不想要菜单:



我建议您考虑在主窗体上使用SplitterPanel,将配置UI放在其中一个面板中,将直接操作用户界面放在另一个面板中。



隐藏配置面板,让用户可以轻松地在需要时看到它。



或者,您可以使用另一个表单,其中包含所有配置控件,您可以在用户想要使用它时显示该表单。使用另一个表单,您将完成将用户在配置表单上所做的任何选择传回主表单的任务。或者,您可以让配置表更新一个主表单和配置表可以使用的静态类。



如果需要,您还可以考虑嵌套拆分面板但是,我认为,这会让你接近你说你不喜欢的标签设计。
You mentioned VLC, but, VLC makes extensive use of menus (top-of-screen unless you select to view full-screen), and context-menus.

If you don't want menus:

I suggest you consider using a SplitterPanel on your Main Form, put your configuration UI in one of the Panels, and your direct-action user interface in the other.

Hide the configuration panel, and give the user an easy way to make it visible when they want to.

Or, you could have another Form with all the configuration controls on it, which you show when the user wants to use it. Using another Form you will have the task of passing-back any choices the user made on the configuration Form to your Main Form. Or, you can have the configuration Form update a static class that both the Main Form and the configuration Form can use.

You can also consider nested splitter panels if you need to, but that, I think, gets you close to the tab ui design you say you don't like.


将控件放入一个可滚动的容器中。



WPF - ScrollViewer控件 - 请参阅如何:创建ScrollViewer [ ^ ]



Winforms - 面板 - 参见如何:滚动表单内容 [ ^ ]



- 响应OP的解决方案

获得首先是那里的控件,你可以使用几种技术。对于所有这些,您必须将面板的AutoScroll属性设置为True。



1.在设计器中使表单和面板非常大。放置您的控件,然后将表单和面板调整到所需的大小。



2.如果有太多的控件可以在您的显示器/工作区中轻松完成,那么请放置控件中任意位置的控件,并使用控件的Location属性来定位它们。如果你有一个图表可以使用预先计算的位置,你可能会发现这更容易。



3.另一种选择(但不一定是好的)是在Form_Load事件中以编程方式定位控件(在面板内) - 图表将有助于此。
Put the controls into a scrollable container.

WPF - ScrollViewer control - see How to: Create a ScrollViewer[^]

Winforms - Panel - see How to: Scroll Form Contents[^]

- In response to the OP's "solution"
To get the controls on there in the first place there are a couple of techniques you can use. For all of them you must have set the AutoScroll property of the panel to True.

1. Make the form and the panel very large in the designer. Position your controls and then resize the form and panel to the desired size.

2. If there are too many controls to do that comfortably in your monitor/workspace then place the controls anywhere within the panel and use the Location property of the controls to position them. You might find this easier if you have a diagram to work from with the positions pre-calculated.

3. An alternative (but not necessarily a good one) is to position the controls (within the panel) programmatically in the Form_Load event - again a diagram will help with this.


这篇关于控制窗体外,使用滚动条移动控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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