DataGridView - Proportional Sizing - c#

I have a WinForm project with a tab control container and several tabs. On 1 tab, I have 2 grids, one on top of the other. The grids stretch all the way across the form when fully maximized or when floating (minimized but not hidden). That part works exactly how I want it to.
However, I want the grids to size proportionally on the vertical axis. I cant find a way to set a % for the height of the grid. Is there some other trick to achieving this? Any tips on what property or combination that I might need to set or investigate? Sorry, I know not much to go on, but any help would be appreciated.

Follow below steps, it will work fine.
Place tablelayoutpanel control in tabcontrol.
Set rows and columns for tablelayoutpanel using the "Edit Rows/Columns"
If you have 2 datagridviews only in this tabcontrol, then set row count 1,column count 1.
Set column1 with Percentage 100 ,row1 with 50%, row2 with 50%
Set tablelayoutpanel dock property to fill.
drag and drop datagridview1 to tablelayoutpanel row1 and set the dock property to fill.
drag and drop datagridview2 to tablelayoutpanel row2 and set the dock property to fill.

Related

anchor not sizing buttons properly and text disappearing how to fix it?

in the video below you can see how my buttons behave when i try to resize the window after anchoring them. My application does not have an exist button for some reason either, could not find a solution online and have no clue on how to fix it for the time being. Sorry for potato quality....
https://youtu.be/6WY_19Qdy4c
Did you know that sometimes anchor cannot fix of what will you want to achieve?
Instead of anchoring you can use tableLayoutPanel?
The only properties of tableLayoutPanel is Dock = Fill;
After that you can now add columns and rows in the table and button inside the cell, it will automatically resize your button.
Add a tableLayoutPanel set Dock to Fill
Click tableLayoutPanel
Edit Rows and Columns (Add Column or Rows Change Absolute to Percent it should be 50%)
Press OK
If you want to span Rows and Columns click the control inside the Cell and find ColumnSpan and RowSpan in the properties

How to make a devexpress table row autosize?

I use a devexpress LayoutControl. the LayoutControlGroup.LayoutMode is Table.
I have two rows. And I set the Size Type to autosize. In each row i have a panel with a dynamic height. the panels have dockstyle fill.
But when I run the row proportions are always like in the designer. And not at all autosizing. What am i missing? Can anyone please help??!?
Dock and AutoSize properties are opposite as you thinking. If your control parent has dock property set to true then you can dock child to the parent control but If parent control is going to be resize according to the content( means child controls) then you have to set size of the child controls.
Let your panels in the row has dynamic with then handle ReSize event of panels and set size of the panel according to the width of the controls then the AutoSize property work well on the rows otherwise it is hard to get desired layout with the current settings.
Refer these for more information:
AutoSize Behavior in the TableLayoutPanel Control
In TableLayoutPanel if Dock = Fill and AutoSize = true then last column/row occupy all remaining space
TableLayoutPanel sizing
Hope this help..

winforms adjust controls to push up vertically when others are invisible

I've create a c# winforms form,
It has a bunch of labels positioned and a flowlayoutpanel.
on certain occasions i set one of the labels and the flowlayoutpanel to visible =false.
As a result i want all labels beneath them to be pushed up - at the moment there is a gap where they were.
Also, I'd like the flowlayoutpanel to grow and shrink depending on the number of items it has.
at the moment it is just the size i set it to be in the designer.
please can you help with these 2 issues.
Thanks
If I got you correctly, I would suggest using a TableLayoutPane with two rows. The top row will contain a docked panel with all the controls that may be hidden. The bottom row will contain a docked panel with all the rest.
Set the top row's SizeType to AutoSize and the bottom row's to 100%.
When you want to hide the controls, set the top panel's Visible property to false. Now, because the top row is AutoSized it will shrink to nothing, causing the bottom row to "jump" up.
The TableLayoutPanel does the pushing. Maybe you can use that if there is no better answer in next time.
First problem:
You may use some simple panels to divide your form, give them the dock.fill property. when you'll hide a panel programmatically, the other panels will fill the empty space left.
Second problem:
You have to set the Autosize property to true.

How to have a dynamically resizing GridViewColumn that scales based on the size of the largest item in the ListView in WPF?

Currently I have some GridViewColumns that use Auto for their Width property, but this only seems to work on startup. After I add new values to the ListView, the GridViewColumns using Auto don't adjust their width.
Any idea on how to do this?
Wrongly understand your meaning ;(
you should set the width by code
Here you are: How to autosize and right-align GridViewColumn data in WPF?
fire it up to blend to ease your design process,
or click off the clips with "8" signs
then it will not drag follow with the size of window (in total of 4 clips and 4 sides)
also make the horizontal scroll bar become visible, then it will add up value and scrollable =D
What are the other columns sizes set to? If they are fixed then the Auto sized column will only be able to grow up to the maxwidth minus those column widths. Have you tried setting their column sizes to *?
-Matt

c# winforms evenly distribute 3 controls

i have 3 custom controls, that i want to place in a resizable window next to each other. when the window is being resized, these controls should also resize, each taking 33% of the available width.
i tried to use a table layout, but it seems the table only grows, but never shrinks.
thanks for any help on this!
You can use a TableLayoutPanel, with 3 columns each of size "33% percent". Then you put each of your control in the panel, and set the anchor property as you wish (for example right-left if your control should resize themselves only on the horizontal plane).
Your TableLayoutPanel should also have its property Dock set to True so that he can occupy all your window and resize accordingly.

Categories

Resources