I'm working on a UserControl that consists of a bunch of ComboBoxes arranged horizontally across the top of the control in a flowlayoutpanel, and a datagridview directly below the flowlayoutpanel that takes up all remaining space on the control. I need to be able to hide all the dropdowns easily, so I have a SplitContainer with Orientation == Horizontal, with the flowlayoutpanel in SplitContainer.Panel1, and the datagridview in SplitContainer.Panel2.
The control hierarchy is as follows:
SplitContainer1
SplitContainer1.Panel1
FlowLayoutPanel1
ComboBox1
ComboBox2
ComboBox3
SplitContainer1.Panel2
DataGridView1
Since the flowlayoutpanel is oriented horizontally and horizontal space is limited, the flowlayoutpanel's WrapContents property is True, so that the dropdowns wrap down to the next row when the control is made too narrow to fit all the dropdowns in one row.
The problem I'm having is that when the flowlayoutpanel wraps its contents down onto the next row, its Height property does not change accordingly. The wrapped rows of the flowlayoutpanel are clipped, and don't force the splitcontainer panel to grow in height accordingly. I've tried to handle the FlowLayoutPanel.Resize event to grow and shrink the SPlitContainer.SplitterDistance property to accommodate the wrapped contents, but the FlowLayoutPanel.Height property does not change when contents are wrapped. I'm stumped. Is the FlowLayoutPanel broken? How can I resize the FlowLayoutPanel's parent container if FlowLayoutPanel.Height always remains the same, regardless of content wrapping?
Thanks
It seems like you're making this a little too complicated for what you need. You can use the built-in docking to accomplish what you want without using the SplitContainer. Set up your form like this instead:
FlowLayoutPanel1 (Autosizse = true, Dock = Top)
ComboBox1
ComboBox2
ComboBox3
DataGridView1 (Dock = Fill)
Then when you want to hide FlowLayoutPanel1 you can just toggle the Visible property to hide/show it.
Related
I'm using a checked combobox reprository item for my gridview, and i add multiple words into cell use by checkedcombobox. I want to autoresize the row cell height to show all content.
working with winform
You will have to handle the gridview's CalcRowHeight event and set the height you want in there.
You also may have to handle the CustomColumnDisplayText so that your cell has values put one below another.
I have a UserControl. In it I have a TableLayoutPanel control with columns and rows. In cell I have basic windows forms controls like textboxes, comboBoxes and checkboxes.
For first two of them if I set their Anchor to Top, Left, Right they are re-sizing when the form is resized so the form looks ok.
Now, I want that when the page is resized the CheckBox to be also in the middle of the cell.
Mention: in each cell I have Panel control in which are placed a label control and one of three mentioned above.
By default a checkBox control is set to align Top-Left. Set it to align none and it will do exactly what you're looking for.
I have to develop a control having one datagrid. now datagridtextcolumn have to be binded with one property of collection created in viewmodel.
based on data i have do one thing...
if for a row no of lines is more than 3 in last column's cell then show a button having text "More" with last cell else with text "Less" and on click of "More" button it should display full text data...
now this layout can be shrined as well as stretched at runtime according to window's height and width using viewbox control or any other way...
so how to achieve this thing any idea???
Basically you want a custom textblock control that displays a max of 3 lines and shows a more button (if there are more than 3 lines of text)*.
The more button expands the textblock and I imagine stays around to collapse it again?
As it sounds like you only have one column (more like a list), rather than customise the datagrid create a usercontrol (with a grid, textblock and button) that does what you want and bind that inside a templated column instead.
You will need to expose the Text property as a dependency property for it to bind to. Most of the details of creating this type of usercontrol are on my answer to this: putting Button inside a TextBlock(or maybe something else) to make it work like the one on video?
Just add your size logic and change the layout to suit your needs.
*Note: Personally I would use the MinHeight property of the usercontrol to set when the "More" button is needed, then it will be more flexible, but that is just a suggestion.
I'd like to create a dropdown panel in WPF the acts like a ComboBox/Expander hybrid. I'm currently using an Expander but it pushes the the controls underneath it down when it expands.
I simply want it to act like a ComboBox and overlay it's dropdown. I've looked at using Popups but they don't move with the underlying window when it's moved.
So, I've concluded that the closest control to my needs is a ComboBox which allows me to put a Grid or StackPanel into its dropdown area.
Any ideas how to achieve this?
I am not exactly sure what you want to do:
But the layout depends very much on the parent control. If your controls are in a Stackpanel all controls will be moved if a control expands or changes its size. If you use a Canvas you can align controls on top of each other.
Also Adorner are useful when you want overlay something above something else.
You can change the appearance of the ComboxBox and you can put a grid or anything else inside it. Have a closer look at ItemTemplate.
I have a TabControl consisting of several TabPages. One of these TabPages contains a TreeView and another contains a DataGridView. I would like these controls (and tabpages) to AutoSize to the maximum size allowed in the TabControl without scrolling.
The DataGridView contains an AutoSize property inherited from Control which garbles the control if enabled. The TreeView does not have this property. I have tried setting the Size equal to TabControl.Size but that does not account for bordersize and the Tabbar height.
treeView.Size = new Size(tabControl.Size.Width - SystemInformation.Border3DSize.Width * 2, tabControl.Size.Height - SystemInformation.Border3DSize.Height * 2);
My question is: how can I determine the height of the Tab buttons or how can I automatically fill TabPages to their maximum size with a single control?
The Property you search is called Dock.
You probably want to set it to DockStyle.Fill on your TreeView and DataGridView.
An alternative would be to set the Anchor Property to AnchorStyle.Top, AnchorStyle.Left, AnchorStyle.Right and AnchorStyle.Bottom (concatenate with binary OR the pipe sign '|').
For that you would need to set the size of the Children to ClientSize