Managing lots of controls in FlowLayoutPanel - winforms

I have a C# 4.0 Winform app, the main form of which is visually divided in half: a TreeView on the left (for navigation of data) and a FlowLayoutPanel on the right. The contents of the FlowLayoutPanel changes based on user interaction (mainly with the TreeView).
The content to be shown in the FlowLayoutPanel is comparmentalized into a number of "blocks" - some are UserControls whilst others (I'm embarrassed to say) are Panels containing various Controls.
My issue is that the number of "blocks" is now too many to see in the Visual Studio form designer, and I can't make the form large enough to see them all; this makes it hard to verify how the UI will look without running it.
How can I manage the contents of the FlowLayoutPanel so that I can see all of the controls, or am I going about it wrong?

While in the designer, make sure you have AutoScroll property set to true, which will enable you to scroll the FlowLayoutPanel child controls while in the designer view.

Related

Create a screen like control panel windows forms 2010

I am building an application and I would like the one of the forms to look like the control panel
Would you use a listview with groups?
thanks
No, I don't think you can make the ListView do this. At least not without rewriting its painting routines.
It isn't going to be easy to replicate this layout precisely in WinForms. There's nothing you can just drag over from the toolbox that is going to do it. It is possible, but it will take some effort.
What I would do, conceptually, is break it up into pieces. I count 8 different repeated "blocks". So I'd create a UserControl that models each of these.
Inside of the UserControl, I'd have a PictureBox control to display the icon, a Label control to display the heading, and a TableLayoutPanel that can be filled with the desired number of LinkLabel controls. Set all of the properties of the controls so that they match, and then write public methods to set the icon, heading, and add/remove links.
Then I'd drop a TableLayoutPanel onto my form, set the margins to have lots of whitespace, and add as many of those UserControls as necessary. At the top of the form, of course, you'd need another Label to display the heading/instruction text. Make the form's background white, and you're pretty much there.
The logic to switch between views isn't implemented, but consider whether you really need that. It is important in Windows because users are used to the old way of doing things. This doesn't apply to you.

Some controls on a page are not visible for MS UI Automation

We have an application with StartPage.xaml, where control template for TabControl defines some grids and stack panels. There is an itemPresenter in that template in the middle of the xaml, and a stack panel below it. While it works fine for a user, MS UI automation can see only tab items inside the item presenter, and nothing else that is defined on the same level in the template.
I tried to add standard button inside a stack panel which can not be seen by MS UIA to check if that is a problem related to custom user controls we have, but that standard button is also not visible for MS UIA.
If I use Snoop, I can see all the elements from the template in a snoop's tree on the corresponding levels of template hierarchy. But MS UIA still can't find them.
What can go wrong here with controls that will prevent MS UIA from finding them on a page?
Finally I was able to detect the problem. TabControl was templated with a bunch of different controls, while AutomationPeer stayed the same which is only aware of TabItems as TabControl children.
I subclassed TabControl and overrode OnCreateAutomation to create and return my GenericAutomationPeer, which can enumerate all child UIElements of this control and voila - UIA Verify can now see that additional controls from TabControl template.
GenericAutomationPeer implementation was found here: http://www.colinsalmcorner.com/2011/11/genericautomationpeer-helping-coded-ui.html
Great thanks to the author of that article!

WPF Context Sensitive Menu Ribbon

im a bit new to wpf.
im trying to make the acclaimed Ribbon the center for all menus and commands of my custom app
now my main window is a tabcontrol with a few major tabs: contacts, sales, appointments,expense etc.
on top of the tabcontrol is a ribbon
(pretty similar to MS Outlook)
for each tab i have different buttons that i need
(the tabs each display a different UserControl as its main content)
plus there are several buttons that should always be in the ribbon (settings, about, new appointment...)
the best would be if i can add the RibbonTabs directly in the usercontrols and somehow merge them auto-magically with the main ribbon at runtime depending on the visible tab
if thats not possible then there is something called ContextualTabGroups, but for the life of me cant find any info on how to bind/trigger the different ribbons to certain cirmcumstances/childcontrols or whatever.
if i need to call .visibilty upon load and close of each usercontrol, then theres nothing "contextual" about that
thank you very much

Is it possible for WinForm controls (Panel,etc.) to grow like a webform control?

I'm converting an app from ASP.NET WebForms to WinForms. There is one asp.net page which contains a ListView/Repeater that contains several custom controls, which in turn contain a ListView with other custom controls. Basically the layout looks like a TreeView, but on each node/leaf there are few controls like comboboxes, etc.
When this is in ASP.NET, the page automatically lays itself out, so it is several screens tall - if I add 20 buttons into a Panel, it will grow and the browser will get scrollbars.
I'd like to do the same thing in a WinForms application - so I'll have a user control that will contain a lot of controls in a some variation of Panel (Flow, Table layout), and the controls might have another controls inside them, etc.
The problem is, that when I make winforms app, each control has specific height in the design time. I'd like some user controls to be able to grow with their contents - so they'll add up. In the main Form, there should be a vertical scrollbar, just like in the web browser when the generated page is taller than the screen.
I'd just like to get some general pointers in the right direction. Thanks.
Use Anchor and Dock container properties.
Yes, to expound on Anchor and Dock...try this
-Place a Panel on an empty form, and set its dock property to Top
-place a textbox in the panel, and Dock it to Full...it should fill the whole top panel
-Place a splitter on the form, and if not already docked correctly, set its dock to top
-place another panel below the splitter, and set its Dock to Fill
-place another textbox inside the lower panel and fill it as as well
Now you have a form with two resiable textboxes and will resize when the form does.
*you may have to set the textbox MultiLine property to true but not sure.
Hope this helps.
Anchor the controls to the parent. Anchoring all four sides will cause it to stretch.
If the Anchoring and Docking answers don't work for you, there is another option. It's not pretty, but you can access a control's properties and change them dynamically during runtime. You'd do something like: if(listBox.Items.Count > [yourVal]) listBox.height = [yourFormula] or something.
It's been a while since I've done a Win Form (and I don't have my IDE fired up at the moment) but I'm pretty sure there's even a ScrollPanel or other scrolling control that you can set on your form.
That said, when you're working with WinForms, the less scrolling you can make your users do, the better.

Automatic proportionate resizing of Windows Form Components?

I have a Windows Forms form in C#.
It is just like a regular Windows GUI application. However I am facing problems making the different components on the form resize themselves according to the window size. I mean I do not exactly know which property of the component is to be changed.
I have a tabPage in the form. The tabPage contains a splitcontainer which has 2 panels in it.
The left panel contains a treeView and the right panel has components like radio buttons, textboxes, comboBox and buttons,etc
When I run my application and resize the window (either by dragging a corner of the window or by hitting the maximize button on top right corner) the Windows Forms form and the tabPage expand but the split container doesn't. It stays where it was. Also I want to anchor the split container so that if I shrink my window, the split cointainer still remain on top left. I am sorry I cannot put screenshots here.
Just set the Anchor property of the SplitContainer to Top, Left, Right, Bottom. Or experiment setting the Dock property to Fill.
Have you tried using a TableLayoutPanel? Windows Forms doesn't have great layout support (compared with, say, Java and WPF) but TLP works reasonably well - until you find a situation where it doesn't do what you want, and then it's a pain :)

Resources