Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

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[^]
 
Share this answer
 
Comments
Member 10813407 20-Apr-15 1:44am    
Thanks. I'll give that a try.
Maciej Los 20-Apr-15 2:11am    
+5
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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900