This is a migrated thread and some comments may be shown as answers.

TableLayoutPanel and Autosizing

8 Answers 1373 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Guillaume Crétot Richert
Top achievements
Rank 1
Guillaume Crétot Richert asked on 28 Oct 2008, 08:14 PM
Hi,

I'm trying to add a few Rad controls to a TableLayoutPanel. For the sake of the example, let's say I have a TLP with 1 column and 2 rows. The top row contains a RadListBox, and the bottom row contains a RadButton. The top row's size is set as Percentage (50%) and the bottom row as AutoSize.

The desired result would be that most of the control's space be filled with the RadListBox, while the RadButton be set at an appropriate size.

The actual result is that the RadListBox takes up all the room, and the RadButton appears as a tiny sliver at the bottom, barely a line. It would seem as if in run-time, the TableLayoutPanel decides to AutoSize the bottom row to a few pixels; whereas in the form designer, the button appears perfect.

What am I doing wrong? How can I get the TableLayoutPanel's AutoSizing rows to play nice with RadControls?

Thank you.

8 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 30 Oct 2008, 08:02 PM
Hi Guillaume Crétot Richert,

Thank you for contacting us.

Please review the attched sample project. Am I missing something while trying to reproduce the issue?

I am looking forward to help you on your problem.
 

All the best,
Nick
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Guillaume Crétot Richert
Top achievements
Rank 1
answered on 10 Nov 2008, 02:36 PM
Apologies for the late response.

In the project you provided, the button's dock is set to "None". It should be set to "Fill". Alternatively, you could also set all the button's anchors instead of only top and left like it currently is.

Once you set the Dock or the Anchors, the button will disappear in run-time (but not in design-time).

Thank you,
Guillaume
0
Nick
Telerik team
answered on 11 Nov 2008, 04:44 PM
Hello Guillaume Crétot Richert,

Thank you for contacting us back.

I see, the reason for that is that autosize uses the size of the inner controls which in the case of RadButton is set to 0. The workaround is to set the row to absolute and use for the size of the row the height of the button. Sorry for the introduced inconvenience.

Do not hesitate to write me back if you have further questions.

Kind regards,
Nick
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Guillaume Crétot Richert
Top achievements
Rank 1
answered on 11 Nov 2008, 06:10 PM
Hi Nick,

That's hardly a workaround. My desired behavior is for the button to be autosized. In the case of a RadButton, the heigth can be determined fairly constantly in advance, but for other controls the size can vary immensely depending on where they should appear. I create user controls that contain Telerik controls and can appear in many different sized frames or forms. It would be archaic to have each form dictate which size each of its buttons should have.

Are there any plans to have RadControls implement AutoSize correctly? It's a pretty big feature to cut out of wincontrols, and I'm surprised this is the first time I read about it being missing from Telerik's product.

Thanks!
0
Accepted
Nick
Telerik team
answered on 12 Nov 2008, 04:55 PM
Hi Guillaume Crétot Richert,

Thank you for contacting me back.

The subclassed RadButton will work correctly in your application.

public class RadButtonElement2 : RadButtonElement 
  protected override System.Drawing.SizeF MeasureOverride(System.Drawing.SizeF availableSize) 
  { 
    if (availableSize.Width == 0) 
    { 
    return new SizeF(23, availableSize.Height); 
    } 
    return base.MeasureOverride(availableSize); 
   } 
 
   protected override Type ThemeEffectiveType 
   {  
     get 
     { 
        return typeof(RadButtonElement);  
     } 
   } 
  } 
 
public class RadButton2 : RadButton 
   { 
      RadButtonElement2 element = new RadButtonElement2(); 
      public RadButton2() 
      { 
        this.UseNewLayoutSystem = true
        this.AutoSize = false
      } 
 
   public override RadButtonElement ButtonElement 
   { 
     get  
     {  
       return this.element; 
     } 
   } 
 
 
   public override string ThemeClassName 
   { 
    get 
    { 
      return typeof(RadButton).FullName; 
    } 
    set 
    { 
      base.ThemeClassName = value; 
    } 
  } 


Do not hesitate to write me back if you have further questions.

Greetings,
Nick
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Guillaume Crétot Richert
Top achievements
Rank 1
answered on 12 Nov 2008, 06:18 PM
Hot damn!

As soon as I get around to it, I'll rewrite your code in VB and try it out. I'll let you know how it turns out ASAP.

Thanks for your time!
0
Nick
Telerik team
answered on 13 Nov 2008, 08:23 AM
Hi Guillaume Crétot Richert,

You may use this online tool to convert the code.

Regards,
Nick
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Guillaume Crétot Richert
Top achievements
Rank 1
answered on 17 Nov 2008, 06:27 PM
Works like a charm!

Thanks Nick!
Tags
General Discussions
Asked by
Guillaume Crétot Richert
Top achievements
Rank 1
Answers by
Nick
Telerik team
Guillaume Crétot Richert
Top achievements
Rank 1
Share this question
or