i'm working on win-form (c#) that contains tableLayoutPanel, the panel contain only one column, but various number of rows with userControl in it, added by user at run time.
each userControl (all the same) contains ultraGrid with various number of lines in it (4-15 max).
the default scenario is that the tableLayoutPanel contains 3 rows, each row contains 1 userControl.
the panel set to autoScroll as the form cannot view all controls.
the issue is while vertically scrolling the panel, it looks really bad, and the userControl seems like stretching until i leave the scroll bar.
is there any way to make the scroll more smooth?
thanks for your help.
Related
In my form I put three charts. I want to fill all available space, and tried to set dock fill, but in this case the charts overlaps each other. I want, instead, to have every chart next to others.
How can I fill all the space, without overlaps?
As mentioned in the comments you want to use a FlowLayoutPanel or TableLayoutPanel. Below are two examples of TableLayoutPanel which may be better because you can more easily control the desired layout.
The examples below use panels instead of grids but the idea is the same for whatever control you want to put inside the TableLayoutPanel.
In both examples, the Dock property of the TableLayoutPanel and all 3 components is set to Fill. This will cause everything to resize automatically as the form resized. Additionally, there is a Rows property and Columns property on the TableLayoutPanel which will allow you to set either pixels are percentages of the table a cell should consume.
Example 1: 3 panels side by side
Example 2: 2 panels above a third panel. In this case you set the ColumnSpan property to 2 on Panel 3
I am using c# and i am creating a simple design where i have a user control and some components inside it like treeviews and buttons. I am trying to fill a treeview with some nodes and drag-drop these nodes to other treeview and use the buttons to also copy nodes from side to another.
The problem i am having is that when i maximize the window containing this user control there is no effect on the inside components.
I have set the Dock property of the user control to Fill.
I have changed the anchor properties of the buttons and treeview inside the user control but the behavior wasn't as expected. For example i have tried to set the anchor property for the right treeview to be Top,Bottom,Left => and the result was a disaster
I have also done a lot of combinations for the anchor property of all the buttons but nothing gave me the right behavior. I just only need to maximize the window form and the controls will be maximized with the same proportion.
It sounds like you want a "3 column" interface where you have a TreeView on either side and Buttons in the middle to allow movement between the two. Assuming this is correct, you can accomplish your automatic resizing by using a TableLayout.
Essentially, it would be like this:
Add a TableLayout and edit the rows/columns such that there is a single row with 3 columns:
The first and last column would be sized at 50% (and would hold your TreeViews).
The middle would be an absolute size of (for example) 120. This would hold your Buttons.
Set the properties of this new TableLayout to Dock -> Fill the form. This will size the entire table to grow with your form.
Add your TreeView controls to the left/right columns and set them to Dock -> Fill the respective columns. Since these columns are dynamically sized, they will grow with the form.
In your middle column, add a Panel and set it to Dock -> Fill. We add a Panel here to hold the multiple Buttons you use for movement. This Panel will not grow in size because the middle column is sized absolutely.
Add your Buttons to the middle Panel.
Without a screenshot, I'm not completely sure what you are trying to achieve but I believe this is along the lines of it. The nice thing about this setup is there is zero code involved.
I have some TableLayoutPanel, where the first "layer" has 1 column and ten rows, some of this rows contain either a UserControl or another TableLayoutPanel with 2 or 3 columns and some rows. One or two of them contain another TableLayoutPanel, but that's it. So that's a maximum of 3 "levels" of nested TableLayoutPanels. Most of these are set to autosize, because some UserControls might change their size. When a form containing such a nested TableLayoutPanel, the UserControls "flicker", it looks like they are loading very slowly.
Do I use too much autosizing?
Or is my Panel too nested?
I don't think the flicker has to do anything with 'auto-sizing' or 'nested panels'.
Please refer another 'S-O' link : How to avoid flickering in TableLayoutPanel in c#.net
Suspend the layout until you've added all your controls on.
TableLayoutPanel panel = new TabelLayoutPanel();
panel.SuspendLayout();
// NOW add controls (including nested-controls) -- do autosizing etc
panel.ResumeLayout();
Also look at using Double Buffering. You'll have to create a sub-class of the TableLayoutPanel. See an example.
Hope this helps.
I have a situation where I am adding multiple User controls (each containintg datagridview control, buttons and radio buttons) in my flow layout Panel (.net 3.5 Winforms). The height of flow layout panel is lesser than grid.
The problem is when I scroll down the the Flowlayout panel vertical scroll and select a cell in the grid the focus moves up at random to a cell, selecting all cells between those two positions.
Suggestions please ?
Thanks!
I think you must be having the same problem as explained in the following URLs:
Why does clicking in a text box cause an AutoScroll panel to scroll back to the top?
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/445af1e5-0f8d-4e4e-ba97-bc6dc72b5c74/
If so, overriding ScrollToControl as explained in the above URLs can help fix the issue.
I have created a user control in which I have a datagrid along with other items.
One of the functionalities of these control is that through two buttons I can add or remove columns from the DataGrid.
Multiple of these controls are placed inside a WrapPanel, to display in my main application.
Now while running my application and I press the button to add a new column to the datagrid, the datagrid changes size and as result the initial user control becomes wider, which means that one of the childs of the wrappanel is wider than the other ones.
If I add multiple new lines and the user control reach the width of the application window then a scrollbar apprears below the datagrid so I can scroll and see all the contents in the datagrid.
Is there any way to prevent this behaviour?
Ideally I am looking for my wrappanel child to have a constant size, and my datagrid directly to present the scrollbar upon addition of a new column in it. Thus all the wrappanel childs have the same width.
I dont want to place a specific constant size to my user control if that is possible.
It is possible to achieve the same result with a Grid than with a WrapPanel, just a little bit less handy.
Starting from a grid you can set Width/MinWidth/MaxWidth (with star notation) and Height/.../... to get the behaviour you want.