Ticket Q373941
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Provide the MinHeight property for the Bar class

How to set Bar Height

created 12 years ago

Hi. I've got the same problem with standard Bar (not a ribbon). When i tried the solution it worked, but with one little problem: the empty EditItem is taking horizontal space on the bar and the first (visible) bar button (added later) is located about 10-20 pixels to the right (from the bar's left edge). I can't align the empty item to the right because all the buttons are getting aligned to the right. Is there a way out of this? Thanks.

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hi,
You can reduce this space by setting the Bar.BarItemHorzIndent property to 0. However, after setting this property the distance between all bar links will be changed.
Please let me know if this approach is suitable for you.
Updated by Nikita
It is a good idea to set a fake element alignment to the right. Please note that when you set a bar item alignment to the right, all bar items that are situated to the right of this bar item will have right alignment as well. To avoid this issue, your fake item must be rightmost before you set its alignment.
Updated by Nikita
If the approach with a skin is not suitable, I have found another solution. Until we implement this option, you can create a Bar descendant and introduce the IDockableObject interface. It is necessary to implement only the IDockableObject.CalcSize method:

C#
public class MyBar : Bar, IDockableObject { private int _MinHeight; public int MinHeight { get { return _MinHeight; } set { _MinHeight = value; } } public System.Drawing.Size CalcSize(System.Int32 width) { Size defSize = BarControl.CalcSize(width); return new Size(width, defSize.Height<MinHeight ? MinHeight:defSize.Height); } }

To use this Bar in your application, replace the Bar class name with your custom one in the Form.Designer.cs file. In this case, you can manage the minimal bar height via the MyBar.MinHeight property.

    Show previous comments (8)
    DevExpress Support Team 12 years ago

      Hi Paweł,
      If the approach with a skin is not suitable, I have found another solution. Until we implement this option, you can create a Bar descendant and introduce the IDockableObject interface. It is necessary to implement only the IDockableObject.CalcSize method:

      C#
      public class MyBar : Bar, IDockableObject { private int _MinHeight; public int MinHeight { get { return _MinHeight; } set { _MinHeight = value; } } public System.Drawing.Size CalcSize(System.Int32 width) { Size defSize = BarControl.CalcSize(width); return new Size(width, defSize.Height<MinHeight ? MinHeight:defSize.Height); } }

      To use this Bar in your application, replace the Bar class name with your custom one in the Form.Designer.cs file. In this case, you can manage the minimal bar height via the MyBar.MinHeight property.
      I have attached a small sample to illustrate this approach.

      Please let me know whether or not this approach meets your requirements.

        Now this is what I need! Works perfectly. Thank you!
        PS: I would mark this as a solution if it had been added as a solution instead of comment.

        DevExpress Support Team 12 years ago

          You are welcome, Paweł. Please contact us if you need further assistance.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.