in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Is Automatic sizing of layout control item possible based on MaxLen property?

Last post 10/29/2008 2:12 PM by Pavel. 8 replies.
Page 1 of 1 (9 items)
Sort Posts:
Previous Next
  • 10/27/2008 12:30 PM

    Is Automatic sizing of layout control item possible based on MaxLen property?

    Hi,

    I spend a massive amount of time fiddling with the layoutcontrol in order to make textedit controls etc.. wide enough for the maxlen property that I have set.

    Is there any way to get the layout control to automaticall size the control based on the max len property and font being used or does everyone spend a lot of time resizing controls?

    Regards

  • 10/27/2008 3:26 PM In reply to

    • Pavel
    • Top 200 Contributor
    • Joined on 7/5/2007
    • Posts 55

    Re: Is Automatic sizing of layout control item possible based on MaxLen property?

    Did you meanSystem.Windows.Forms.TextBoxBase.MaxLength? True type font letters may have variable widthes.

    Let me detalize the suggestion. Automatic calculation of the MinSize should look like.

    MinSize = Math.Max(current tem MinSize,  MaxLength* 'W' letter with on current appearance settings);

    I think it is must be feature. For example, date edit must always show full date line it is useless if it shows half line.

    WPF HATER BLOG
    http://wpfhater.blogspot.com/
  • 10/28/2008 3:00 AM In reply to

    Re: Is Automatic sizing of layout control item possible based on MaxLen property?


    Hi guys,

    We already have this feature.

    Each BaseEdit successor has the AutoSizeInLayoutControl property. At the moment, this property is not available in the property grid for all editors. So, you can manage it via code. Here is a code snippet

           private void Form1_Load(object sender, EventArgs e) {
               this.textEdit1.AutoSizeInLayoutControl = true;
               this.dateEdit1.AutoSizeInLayoutControl = true;
           }
    You can change the AutoSizeInLayoutControl property's default value by creating your own successors like this

       public class MyAutoSizeTextEdit : TextEdit {
           public MyAutoSizeTextEdit() {
               AutoSizeInLayoutControl = true;
           }
       }

     

    Thanks, Roman

    R&D, .NET Team
    Developer Express Inc.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/Support/Center
  • 10/28/2008 10:42 AM In reply to

    Re: Is Automatic sizing of layout control item possible based on MaxLen property?

    Roman K (Developer Express):


    Hi guys,

    We already have this feature.

    Each BaseEdit successor has the AutoSizeInLayoutControl property. At the moment, this property is not available in the property grid for all editors. So, you can manage it via code. Here is a code snippet

           private void Form1_Load(object sender, EventArgs e) {
               this.textEdit1.AutoSizeInLayoutControl = true;
               this.dateEdit1.AutoSizeInLayoutControl = true;
           }
    You can change the AutoSizeInLayoutControl property's default value by creating your own successors like this

       public class MyAutoSizeTextEdit : TextEdit {
           public MyAutoSizeTextEdit() {
               AutoSizeInLayoutControl = true;
           }
       }

     

     

     I have tried setting this property but with no joy. I do have an editmask on a spinedit control of #######.00 but it doesn't seem to resize it.


    What I need is the box to be the correct size on size changes on the screen so if for example the user maximizes the screen, the spin edit box should stay the same size which I know I can do by locking the size.


    The problem is that if I size the box so it looks correct on my screen, then run the app on my bosses laptop which is a different monitor and more widescreen, it is the wrong size e.g. 9999999.99 will show as 999999.99 (cutting off the last 9).

    Is there anyway around this or is it something to do with my layout?

     

    Regards

     

  • 10/28/2008 12:41 PM In reply to

    Re: Is Automatic sizing of layout control item possible based on MaxLen property?

     Also, autosizeinlayoutcontrol does not appear to have any effect in lookupedit controls. Is it meant to or could it be something to do with my layout?

  • 10/29/2008 3:43 AM In reply to

    Re: Is Automatic sizing of layout control item possible based on MaxLen property?


    Mike, thank you for reporting this. I have reproduced an incorrect behavior of the SpinEdit control. Definitely, it is a bug. I have registered it as B33597.

    As for LookUpEdit control, it works fine for me. To test the AutoSizeInLayoutControl property, I have placed empty space and LookUpEdit on the empty  layoutControl side by side. Also, I reduced LookUpEdit's width to the minimum. The following code was placed into the form load event handler:

     private void Form1_Load(object sender, EventArgs e) {
                lookUpEdit1.AutoSizeInLayoutControl = true;
                List<string> items = new List<string>();
                items.Add("one one");
                items.Add("one one one");
                items.Add("one one one one");
                items.Add("one one one one one");
                this.lookUpEdit1.Properties.DataSource = items;
            }

    Could you please qualify the scenario when the AutoSizeInLayoutControl fails for the LookUpEdit control?

    Thanks, Roman

    R&D, .NET Team
    Developer Express Inc.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/Support/Center
  • 10/29/2008 5:18 AM In reply to

    Re: Is Automatic sizing of layout control item possible based on MaxLen property?

     Roman,

    Are you saying that if I use autoSizeInLayoutControl with a mask, the spinedit should always be sized correctly even on widescreen resolutions? Is that the bug?

     

     

  • 10/29/2008 6:08 AM In reply to

    Re: Is Automatic sizing of layout control item possible based on MaxLen property?

     Roman,

    I have found the problem with the lookup edit. It would appear that you have to set autoSizeinlayoutcontrol before assigning the datasource for it to work. I was setting it after the datasource.

     

     

    Roman K (Developer Express):


    Mike, thank you for reporting this. I have reproduced an incorrect behavior of the SpinEdit control. Definitely, it is a bug. I have registered it as B33597.

    As for LookUpEdit control, it works fine for me. To test the AutoSizeInLayoutControl property, I have placed empty space and LookUpEdit on the empty  layoutControl side by side. Also, I reduced LookUpEdit's width to the minimum. The following code was placed into the form load event handler:

     private void Form1_Load(object sender, EventArgs e) {
                lookUpEdit1.AutoSizeInLayoutControl = true;
                List<string> items = new List<string>();
                items.Add("one one");
                items.Add("one one one");
                items.Add("one one one one");
                items.Add("one one one one one");
                this.lookUpEdit1.Properties.DataSource = items;
            }

    Could you please qualify the scenario when the AutoSizeInLayoutControl fails for the LookUpEdit control?

     

     

     

  • 10/29/2008 2:12 PM In reply to

    • Pavel
    • Top 200 Contributor
    • Joined on 7/5/2007
    • Posts 55

    Re: Is Automatic sizing of layout control item possible based on MaxLen property?

    Let's take a look inside. I have used reflector, loaded XtraEditors into it and searched for the autoSizeInLayoutControl.

    Analyzing used  by chain showed that this property is used in two places(shown below). In both plases CalcBestSize method is called. This is documented method http://www.devexpress.com/Help/?document=xtraeditors/devexpressxtraeditorsbasecontrol_calcbestsizetopic.htm. CalcBestSize does not take mask into account, it calculates editor's with using its current content. Calculating editor's with using it's mask is incorrect, since letters has different widthes(for example 'i' and 'w').

    protected override Size CalcSizeableMinSize()
    {
        return (this.AutoSizeInLayoutControl ? this.CalcBestSize() : new Size(50, this.CalcBestSize().Height));
    }
    
    protected override Size CalcSizeableMaxSize()
    {
        return (this.AutoSizeInLayoutControl ? this.CalcBestSize() : base.CalcSizeableMaxSize());
    }
    

    
    

    WPF HATER BLOG
    http://wpfhater.blogspot.com/
Page 1 of 1 (9 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED