Automatically expand WinForms panel vertically to bottom of container - winforms

I am trying to establish the following behavior: When hiding the bottom (blue) panel I want the top (red) panel to stretch to replace it vertically and vice versa (hiding red panel should expand blue).
Using a table layout panel with auto sized rows I was able to get the blue to stretch upwards but I can not get the red panel to grow downwards.
It's difficult to see from the far right picture but the bottom table row did not shrink with the panel. Table layout panel is not a requirement for me but I was hoping it would offer a solution.

Try using a SplitContainer control instead.
You can control each panel's visibility with the Collapsed properties:
splitContainer1.Panel1Collapsed = true;
or
splitContainer1.Panel2Collapsed = true;

Related

How to scroll a DevExpress Xtragrid horizontally but by full columns

I want to scroll a grid horizontally. By default, it scrolls pixel by pixel. I want to scroll column by column. Simply, a column should shift to left/right 100% or 0%. Shouldn't scroll by a fraction of it's width. (This applies to the first column visible to the user at the moment).
What I want is a way to do "snappy" scroll.
How can I get this done?
To scroll grid's content, use the GridView.LeftCoord property. To access boundaries of columns, the GridViewInfo.ColumnsInfo collection will be helpful. You can see how to implement this feature in the How to implement scrolling by columns in the grid e2481 example.

get horizontal scroll bar instead of cutting off winform when made smaller

I'm using a winform. When I set the width to a little too small, or user adjusts my form width, some of my controls are getting cut off. The behavior that I'm looking for is a horizontal scroll bar appearing in this situation.
The issue is with the top panel of my form. This is my setup.
I have a panel - Dock = Top
In it, I have one panel (pnlHeaderLeft) - Dock = Left and another panel (pnlHeaderRight) - Dock = Right
In pnlHeaderLeft, I have a drop down and 2 buttons with anchor = top, left.
In pnlHeaderRight, I have a devex layout control with Dock=fill.
Can an expert pls assist?

Show/hide Grid Row when mouse is over grid

I have a Grid with two rows which are aligned at the bottom of my window.
By default the top row is always visible and the bottom is hidden. What I would like is when the mouse is over the grid, for the bottom row to display with animation rising up from the bottom.
Could someone help me with this.
Put the buttons in a panel, say a StackPanel, and place the StackPanel in the bottom row.
Then add a RenderTransform to the panel and animate the transform.

Windows forms app, autoscale controls with form

I'm a newbie. Designing a form that can be resized, and I want my textboxes, labels and buttons to resize with the form, can someone tell me how to do this?
It depends on the type of layout you need. The "basic tools" you have to do that are following properties: Anchor and Dock.
Anchor
With the Anchor property you "attach" a side of an element to a side of its container. For example if you place a button in the bottom-right corner of a window and you set "Bottom, Right" as Anchor then when you'll resize the form the button will keep its relative position to that corner.
Now imagine you place a multiline text-box in the form, resize as needed (for example 4 px from top, left and right border and 128 px height) and set the Anchor property to "Left, Top, Right". When you'll resize the form that control will keep its height but it'll resize to keep its margins (so if you'll make the form wider its width will be increased).
Dock
Dock is different. With docking you "say" to the Layout Manager to use all available space in one direction. For example if you set to Left then your control will keep its width but it'll use all the available height and its location will be most left as possible.
You may have more than one control docked in a container, imagine you have 5 textbox with Top docking inside a form. They'll be stacked to the top of the form using all the width (and resizing). Another example: a Top docked control (as a banner) and a "Fill" docked control (as main content). Remember that with docking the order of controls matters (if you first place the "Fill" control it'll use ALL the available space and the "Top" dock control will overlap).
Even more
Moreover you have some layout controls too (tables and stacks). They're really easy to use and a 30 minutes of "experiments" will clarify much better than a long text.

Expander with GridSplitter

I've a grid splitter before to the expander(which exists in the right side of a wpf window) and when i was running the app i need to use grid splitter to see more data from expander after its expanded, but the problem is when i was drag splitter i'm getting full view of my expander irrespective of original width but after click on expander to collapse it won't go to its original position by maintaining the splitter dragged width. So any one help me how can i send back expander to its original position.
Thanks,
#nagaraju.
Once you have used the splitter the grid column widths will no longer be 'auto'.
One solution is to respond to the collapsed event of the expander and reset the width of the first column to auto using column.Width=GridLength.Auto;
As you are resizing the contents of the Expander it may make more sense to place the GridSplitter inside the Expander, and on the outside you just have a normal Grid which makes the cell where the Expander is size to content.

Resources