What is this tool called in the toolbox of visual studio? - winforms

I'm talking about the White boxes with red colored border that you store labels and textboxes. I have found a similar tool I think, it's called the TableLayoutPanel. But I can't insert more than 1 stuff in each column (or boxes).

Yes, you are looking at the TableLayoutPanel control, which is designed to allow only a single control in a cell. So to get multiple controls into a single cell would require a UserControl or a container control, like a Panel, and set the dock style to Fill.
One way to get the red borders is to set all of the child UserControl or Panel control's Margin properties to zero, set the TableLayoutPanel's CellBorderStyle = Single, and then use the TableLayoutPanel's paint event to just draw the background:
void tlp_Paint(object sender, PaintEventArgs e) {
e.Graphics.Clear(Color.Red);
}

Related

wpf datagrid FrozenColumnCount and usercontrol with adorner

i have a DataGrid with FrozenColumnCount set to one and some DataTemplateColumns which contains a control which uses an adorner (simply lets say a TextBox with an Adorner which shows the Text "Unit" or somelike). If I use the HorizontalScrollbar the adorner lays before the fixed column. How can I solve this problem.
This is the nature of Adorners, they will always be on "top".
Anything placed in the adorner layer is rendered on top of the rest of
any styles you have set. In other words, adorners are always visually
on top and cannot be overridden using z-order.

WinForms : how to add toolStrip to a form already divided into left/right panes using a SplitContainer control

My form is divided up into left and right panes, and the right pane is split into upper and lower panes:
AAAABBBB
AAAACCCC
There's a menu-strip at the top, below the title-bar and a status bar at the bottom:
menuStrip
AAAABBBB
AAAACCCC
status
Now I would like to add a toolStrip below the menuStrip. But when I do so, the toolStrip obscures the topmost content of the panes created using the splitContainer control. The Dock for the toolStrip = Top.
What am I doing wrong that the toolStrip doesn't simply get inserted between the menuStrip and the splitContainer control, pushing the splitContainer control down, so to speak?
You have to play with the BringToFront and SendToBack context menu items of those controls in the designer.
Drop the toolstrip container onto the form, then open the Document Outline window to re-arrange the controls into the correct hierarchy.
There are 2 simple ways of doing that:
Method 1
Open Document Outline window: View\Other windows\Document outline. Use buttons to place your control in the correct place
Method 2
Notice, that the current control in designer form is marked with some kind of focus rectangle.
You can easily navigate through current control parents using Esc key: once pressed, it can be used to go exactly one parent up in hierarchy.
Knowing the above just place your control in any place, cut it and then past it in the correct container. Repeat the step for any other control which is not in a good position
When you need to change the order of control in the same container use Bring To Front and Bring To Back from context menu
You have to set the splitcontainer's dock to none and instead use its anchor settings

Silverlight - Fill a Rectangle (or other controls which have a Brush Property) with a custom UserControl

I need to fill a Rectangle with a custom UserControl. The rectangle's .Fill property accepts a Brush and in Silverlight there is no equivalent for VisualBrush.
I've found this post - http://chriscavanagh.wordpress.com/2009/09/24/silverlight-visualbrush-and-rounded-corners/ - with a possible solution. However this approach requires the UserControl (which will be used to fill the rectangle) to be rendered first outside the rectangle so that the VisualImage can convert it to a WritableBitmapImage.
Does anyone know any alternate solution? I would prefer not having to render the user control outside the rectangle and remove it afterwards, because there is the possibility for some flickrs to occur.
Thanks and best regards,
Bruno
There is no alternate solution if you must be using a rectangle and brush for its fill.
I take it you already have a reason not to simply use a Border containing the UserControl directly? If you don't want the usercontrol to response to the mouse you could include in the Border a Grid containing both your UserControl and a Rectangle with a transparent fill.

FlowLayoutPanel AutoSize height not working

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.

Programmatically Change Individual Cell Borders in a WinForms DataGridView

I need to programmatically change the border of individual cells in a WinForms DataGridView. When searching on the 'net, I found this link (http://bytes.com/groups/net-vb/501128-changing-datagridview-cell-borders-runtime) which is the same thing that I am trying to do; however, there isn't a code example there of the solution, which is
"So you can inherit from the
DataGridViewCell class and overrides AdjustCellBorderStyle method to get a
customized version of DataGridViewCell. Then you can use this customized
DataGridViewCell in your DataGridView.
Note:
In your customized DataGridViewCell, you should expose a
DataGridViewAdvancedBorderStyle public member so that DataGridView code can
set this member border style information to the cell. Then in the
AdjustCellBorderStyle implementation, you should check the this
DataGridViewAdvancedBorderStyle public member and return corresponding
DataGridViewAdvancedBorderStyle. Then DataGridView PaintCells can use it to
paint your cell.".
I'm having a hard time understanding implementing this solution. Could someone please translate the above into working VB.Net code and provide an example of calling it to change an individual cell's borders?
Here is a ready made example which does what you need, just hidden amongst the extra functionality of setting the background colour.
http://www.codeproject.com/KB/grid/hulihui_CustomDataGridVie.aspx
Look for the lines
// must draw border for grid scrolling horizontally
e.Graphics.DrawRectangle(gridPenColor, rect1);
That line draws a cells border, so to change an individual cells border change the Event args (CellBackColorEventArgs class) to include whatever properties you want to describe the border. Then in the DrawCellBackColor method draw the border based on these passed in properties (and whatever else you want to draw in the cell)

Resources