I'm using vb.net 2017. I want to put some panels and dock them in order to create a configuration like in the attached image:
So these panels must be docked and occupies the entire form.
I've tried several docking mode , also I used the Send to back / Bring to to front but I can't do like I want.
How can I do it?
This is what I do, add a TableLayoutPanel to the form and set Dock to Fill.
Then I would add some rows and columns to it so I could combine them to produce the results. Based on what I see it looks like you should end up with 5 columns of 20% and 4 rows of 25%.
Then drag a Panel to the top left cell of the TableLayoutPanel.
Set its:
.Column = 0
.ColumnSpan = 2
.Row = 0
.RowSpan = 3
.Dock = Fill
Follow this procedure and add two more panels. One will start at row 0, column 2 and the other at row 3 column 0.
You might need to play around with the numbers to achieve the desired results. When you get what you want you can set the margins of all of the panels to 0.
I use background colors on all the panels so I can see what it looks like while setting this up.
Related
I am working on a project in VB.Net, and am using a Table Layout Panel to allow for multiple windows to be open side by side with one another.
The issue I am dealing with right now is figuring out exactly which Column of the Table Layout Panel components are placed in at run time.
For example, let's say I have two Windows open, with 3 Columns. So there are controls in Columns 1 & 2, and Column 3 is empty. If I close the Window in Column 1, I want to detect the Column it was in, so that I can shift the Window in Column 2 over to Column 1. I'm trying to do this so I can resize the windows based on how many windows are being opened side by side.
However I can't seem to find a way to determine exactly while Column is the 'parent' Column. The parent container is the Table Layout Panel itself, but I don't know how to get the information I am looking for.
You can determine the position of a child control inside a TableLayoutPanel using its GetPositionFromControl() method, which will return a TableLayoutPanelCellPosition structure, identifying the Column and Row of the cell that a control is occupying:
Dim Position As TableLayoutPanelCellPosition =
TableLayoutPanel1.GetPositionFromControl([ControlName])
Position reports Position.Column and Position.Row as Integer values.
You can also detemine which child control is occupying a specified position, using the GetControlFromPosition() method:
Dim MyControl As Control = TableLayoutPanel1.GetControlFromPosition(0, 0)
Cutting right to the chase, I have a tab with 4 Excel Tables stacked on top of each other. Each row has its own "up" and "down" buttons in the column to the left of the table, like this:
I shrunk the buttons to fit within the same cell (rowheight of 20). This allowed me to use the cell's TopLeftCell.Row property as follows: When clicked, stuff from the button's row is copy-pasted to the row above/below. This is the basic code:
currRow = ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row
If InStr(Application.Caller, "Up") > 0 Then
Move_Project_Up currRow
Else
Move_Project_Down currRow
End If
When the user gets to this tab, any empty table-rows are hidden (with a Rows(rr).EntireRow.Hidden = True). The buttons Move and size with cells so they are automatically hidden). All visible buttons work as expected. However, sometimes a user wishes to move a project from the top of one table "up" to the bottom of the above table (i.e. to a currently hidden row). You can imagine wanting to move data from row 312 "up" to row 244 in the image below:
The code successfully makes the move and unhides the row. HERE'S THE PROBLEM: when the row is unhidden, the buttons are dark gray and their TopLeftCell.Row is wrong:
They are NOT disabled. When clicked, they still trigger the assigned macro. However, I can see from a Debug.Print that their TopLeftCell.Row is not necessarily the row they are actually in. In the image above, BOTH SETS OF BUTTONS have a TopLeftCell.Row of 97. That's correct for the first set, but not the second.
Any thoughts on why this might be happening? I suspect it has to do with the unhiding of the rows, and/or the fact that there's a lot happening on this tab (e.g. over 10,000 array formulas).
Thanks in advance!
As one commenter (jkpieterse) suggested, setting the .Top property of the "broken" buttons to the .Top value of a cell in the same row worked!
I try to implement the following in winform vb net project (I see this work in an app written in delphi).
I wish to hide or set visibility to false of the bottom row that partially visible in dgv that is docked to fill.
I tried to implement something like this:
DataGridView1.Rows(DataGridView1.DisplayedRowCount(true) - 1).Visible = False
I think it should be called during DataBindingComplete and Resize/scroll events, but it doesn't work.
Do you have any ideas / solutions?
So what I use on one of my datagridviews is:
Dim ind As Integer = 0
ind = DataGridView1.Rows.Count - 1
DataGridView1.Rows(ind).Visible = False
which hides the last displayed row of the datagridview.
You requirement sounds somewhat odd. Your comment ”I wish to hide or set visibility to false of the bottom row that partially visible in dgv that is docked to fill.”... I am curious how you would know this is the last row? Is it not possible that there are more rows below the last one visible? If the scroll bars are available you should see the vertical one if rows go beyond its bounding box. If one of the rows is cut in half by the bounding box and there is more than 1 row below this row, then making invisible/hiding/deleting that row will simply move the next one up.
Since the DataGridView is docked you may have to resize the rows manually if you do not want the rows to be split by the bounding box. Another possible solution is to use the DataGridViews AutoSizeRowsMode Like below.
dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells;
This will set the rows so that a row will not be chopped if it is outside the bottom of the bounding box. The rows will auto size to fit evenly There are seven (7) AutoSizeRowsMode options and I am guessing one of them may do what you are looking for. I am guessing DisplayedCells may work for what you describe. If the grid is re-sized often, you may have to implement this row resizing. Hope this helps.
Currently when I maximize my form it resizes as it looks below.
This is due to the anchoring element stretching the two bottom panels on the left as well as causing a gap on the right since nothing is anchored right. I could fill the gap on the right by anchoring the right most panel however that would just cause it to be wider than all the other panels.
What I want is an equal resizing of the panels when the form is maximized as depicted below
How can this be achieved?
Use TableLayoutPanel:
Add TableLayoutPanel to the form and set Dock = Fill
Add 2 rows to the TableLayoutPanel (by default there is already two)
Row 1 - Height = 50%
Row 2 - Height = 50%
Add 4 columns to the TableLayoutPanel (by default there is already two)
Column 1 - Width = 25%
Column 2 - Width = 25%
Column 3 - Width = 25%
Column 4 - Width = 25%
Four panels on the left side put inside every cell of first and second columns and set Dock = Fill
Two panels on the left side put in the third and forth columns of the first row, set RowSpan = 2 and Dock = Fill
I have used CheckedListBox control in vb.net application.
I have several items as follow, item 1, item 2, item 3........item 100.
Now, i want all these items to arrange into three columns and then appear verticle scrollbar.
But, in CheckedListBox, it appears as horizontally. i want it to appear horizontally for just three columns and then vertical scroll should enable.
Can you please suggest if possible in CheckedListBox control or any other control and if possible then how i would have to set its property to achieve this.
I don't think you can do that in a CheckedListBox....
You could create a FlowLayoutPanel, with a fixed width and add AutoScroll = True.
Then add a number of CheckBox controls to it.
You could have problems regarding column alignment and margins. If that's the case, you can set the checkbox Autosize = False and make them a little larger (in order to contain the text)
Or you can reduce the Height of the checkboxes to reduce spaces (is this what you want?)
eg. Height = 15
Use repeat direction =horizontal and repeat column =3 for checkbox list