初学者帮助windows窗体 [英] Beginner help with windows forms

查看:68
本文介绍了初学者帮助windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sooo ...首先,我来自C ++ / C#的背景,我对Windows表格知之甚少。我只想使用它们,因为我有一个使用Windows窗体的文本编辑器示例,放入控件等等似乎相当简单。如果我应该采取不同的路径,我愿意接受建议。



这就是我的困境 - 我想用一个垂直分隔线来划分大约三分之一的距离我的编辑器窗口(或有一个单独的窗口)并使用较小的区域作为宏列表。我希望能够添加/修改/删除宏,而不是使用组合键(这是我可以在当前可用的编辑器中找到的宏 - 因此这个项目),我希望能够单击一个按钮(或者宏文本身可能是按钮)并将宏插入当前插入位置。



如果有人有任何建议或一些示例代码指出我,我将非常感激。

Sooo...first of all, I'm coming from a background of C++/C# and I know very little of Windows forms. I've only thought to use them because I have a text editor sample that uses a Windows form and it seems rather simple to drop in controls and such. If there's a different path I should take, I'm open to suggestions.

Here's my dilemma - I want to use a vertical divider to section off about a third of my editor window ( or have a separate window ) and use the smaller area for a list of macros. I want to be able to add/modify/delete macros, and instead of using a key combination ( which is all I can find for macro use in currently available editors - thus this project ), I want to be able to click a button ( or maybe the macro text itself will be the button ) and have the macro inserted at the current caret position.

If anyone has any advice, or some example code toward which to point me, I'd be most grateful.

推荐答案

尝试使用 SplitContainer class [ ^ ]。



几个视频可以帮助您入门 -

如何使用SplitContainer控件 [ ^ ]

C#WinForm SplitContainer控件教程 [ ^ ]
Try using the SplitContainer class[^].

Couple of videos to help you get started -
How to use the SplitContainer control [^]
C# WinForm Tutorial of SplitContainer Control[^]


如果用于宏的屏幕区域应该是运行时大小的,那么请使用SplitContainer控件,如Abhinav建议的那样。



如果区域大小固定,请考虑使用两个面板,一个停靠在右侧,另一个停靠左侧。根据需要激活ScrollBars:'AutoScroll = true;



UI设计的其他一些想法:



1.在'内容区域(右?)中使用TextBox或RichTextBox并将'Dock设置为填充。如果你将TextBox设置为'Dock,那么你需要设置TextBox'ScrollbarEnalbed和'Scrollbar属性来显示滚动条(如果你把TextBox放在Panel中)。



2.对于宏区域,您可以探索几种策略:这里提到的所有策略都涉及通过添加堆叠宏区域中用于宏(Control或UserControl)的任何控件的想法Control / UserControl到宏面板(或SplitContainer面板)的ControlCollection,并将插入的Control / UserControl的Dock属性设置为'Top。



a。每个宏只使用一个简单的TextBox;使用自定义键来触发宏的应用程序,编辑和删除。例如alt-x触发删除; alt-return触发宏内容插入当前插入点的内容区域; alt-e触发编辑工具的演示。



b。考虑创建一个将用于每个'宏的自定义UserControl。这个UserControl可以包含一个Button,用于触发将宏内容插入到内容中......当然还包括用于宏内容的TextBox。在过去,我创建了一个手风琴,有点像这样,点击按钮将内容添加到其他Control的内容中,按住Alt键单击按钮,展开UserControl及其内部TextBox以填充其容器的整个空间用于编辑。



注意:使用垂直堆叠在面板或其他容器控件中的控件来模拟手风琴样式界面非常简单。如果您对如何执行此操作有疑问,请发布问题。
If the areas of your screen used for "macros" should be run-time sizable, then do use a SplitContainer Control, as Abhinav suggests.

If the areas are fixed in size, consider using two Panels, one docked 'Right, the other docked 'Left. Activate ScrollBars as needed by: 'AutoScroll = true;

Some other ideas for the UI design:

1. in the 'content area (right ?) use either a TextBox or RichTextBox with 'Dock set to fill. if you set a TextBox to 'Dock, then you will need to set the TextBox 'ScrollbarEnalbed and 'Scrollbar properties to show scrollbars (if you have put the TextBox in a Panel).

2. for the "macro" area there are several strategies you could explore: all of the strategies mentioned here involve the idea of "stacking" whatever Control you use for macros (Control or UserControl) in the macro area by adding the Control/UserControl to the ControlCollection of the macro Panel (or SplitContainer Panel), and setting the Dock property of the inserted Control/UserControl to 'Top.

a. use only a simple TextBox for each Macro; use custom keys to trigger application-of, editing, and removal, of macro. for example alt-x triggers removal; alt-return triggers insertion of macro contents into content area at current insertion point; alt-e triggers presentation of an editor facility.

b. consider creating a custom UserControl that will be used for each 'Macro. this UserControl could include a Button for triggering the insertion of macro content into the content ... as well as, of course, the TextBox for macro content. In the past I've created an "accordion" somewhat like this where a click on the Button added content to some other Control's content, and Alt-click on the Button expanded the UserControl and its internal TextBox to fill the entire space of its container for editing.

Note: it is very simple to simulate an "accordion" style interface using controls which are vertically stacked in a Panel or other Container Control. If you have a question about how to do this, please post the question.


这篇关于初学者帮助windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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