Declined
Last Updated: 18 Sep 2014 08:29 by ADMIN
ADMIN
Boryana
Created on: 07 May 2012 02:30
Category: UI Framework
Type: Bug Report
6
FIX. Anchor Issue in UserControl docked in RadPageView
DECLINED: not an issue.

Steps to reproduce:
1. Create a UserControl, drag a RadControl and set its Anchor to Left, Top, Right, Bottom
2. Drop a RadPageView on the main form and create a RadPageViewPage.
3. Place the newly created UserControl on the page and set its Dock to Fill
The Control located in the UserControl will exceed the visible page area
2 comments
ADMIN
Ivan Todorov
Posted on: 18 Sep 2014 08:27
Hi Joerg,

Now that this case has been put to development, I have checked the sample project from the originating support thread and it appears that the wrong sizing is present because of the way your code is organized and this is actually an expected behavior in your case. 

The thing that is more specific in your project is that you are instantiating child controls at run time and not using designers. Basically, when you have anchored controls, they will update their size every time their parent's size has changed unless the parent layout was suspended using SuspendLayout (this method is automatically called in the designer files as you may have noticed). So, here is what happens in your project:

1. You create a RadPageViewPage - it is not yet added to the page view and its size is (100,100).
2. You create a user control which contains RadGridView anchored to all sides. The UserControl's size is about (500,450) and the location of the grid is (0, 180).
3. You set Dock.Fill to the user control and add it to the RadPageViewPage. Since the page's size is (100,100), the user control is also resized to (100,100) and then the size of the anchored controls in it is updated. Since the grid's location has Y = 180 but its size cannot be negative, the size of the grid is set to (x,0).
4. You add the RadPageViewPage to the RadPageView. Now the page updates its size to fit the page view. Lets say the page gets a size of (500,500). Since the previous size of the page was (100,100), the delta in the size is (400,400) and this delta will be added to the size of the anchored grid. However, its height was clamped to 0 instead of getting a negative value, so now the height will become 400. Its location is still Y=180, so the bottom of the grid will be outside the page boundaries.

The difference comes from the fact that the height of the anchored grid cannot be negative and is set to 0 at step 3. Again, the behavior is present because you initialize the control hierarchy dynamically without suspending the layouts of the individual controls. For example, in the case above, if you add the page to the page at an earlier step, you could avoid height of the grid getting incorrectly updated. 

The proper solution is to call SuspendLayout during initialization on all controls being involved and then ResumeLayout when the initialization is done. This is just how the layouts in the WinForms platform work and the behavior is expected.

If you have any questions or difficulties with the anchoring, please contact us via our support ticketing system.
Jesse Dyck
Posted on: 29 Jan 2013 14:01
Is there any ETA on when this gets fixed.. this happens -all- the time throughout our applications, not only with RadPageView's but also with RadGridViews, RadDropDown boxes etc.. the sizing -rarely- is calculated correctly when placing Telerik's controls