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.
We have closed this ticket because another page addresses its subject:
Provide the MinHeight property for the Bar classHow to set Bar Height
Answers approved by DevExpress Support
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.
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.