Skip to main content

NavBarGroup.CalcGroupClientHeight Event

Fires when the group’s client height is calculated.

Namespace: DevExpress.XtraNavBar

Assembly: DevExpress.XtraNavBar.v24.1.dll

NuGet Packages: DevExpress.Win, DevExpress.Win.Navigation

Declaration

public event NavBarCalcGroupClientHeightEventHandler CalcGroupClientHeight

Event Data

The CalcGroupClientHeight event's data class is NavBarCalcGroupClientHeightEventArgs. The following properties provide information specific to this event:

Property Description
Group Gets a group for which the event is fired. Inherited from NavBarGroupEventArgs.
Height Gets or sets the group’s client area height.

Remarks

Write a CalcGroupClientHeight event handler to assign custom height to the group’s client area. The event fires only if the paint style of the control doesn’t imply that group headers are moved to the opposite side of the control when corresponding groups are expanded/collapsed.

Example

The following sample code handles the NavBarControl.CustomDrawGroupClientForeground event to custom paint the text on a group’s client foreground. The group doesn’t contain any links initially and thus the NavBarGroup.CalcGroupClientHeight event is handled to specify the group’s height.

The image below shows the result.

CustomDraw - GroupClientForeground

using DevExpress.XtraNavBar.ViewInfo;
using DevExpress.XtraNavBar;

readonly Font mailFont = new Font("Verdana", 8, FontStyle.Bold);
readonly Font siteFont = new Font("Verdana", 8);
private void navBarControl1_CustomDrawGroupClientForeground(object sender, 
  CustomDrawObjectEventArgs e) {
    // Identifying the processed group.
    NavGroupClientInfoArgs info = e.ObjectInfo as NavGroupClientInfoArgs;
    if(info.Group.Caption != "Support Info") return;

    // Specifying the text rectangle.    
    Rectangle rect = e.RealBounds;
    rect.Height /= 4;

    // Formatting the output string.
    using(var outStringFormat = new StringFormat()) {
        outStringFormat.Alignment = StringAlignment.Near;
        outStringFormat.LineAlignment = StringAlignment.Center;

        // Painting the first string.
        rect.Offset(0, rect.Height);
        e.Cache.DrawString("E-mail:", mailFont,
            Brushes.Black, rect, outStringFormat);

        // Painting the second string.
        rect.Offset(0, rect.Height);
        e.Cache.DrawString("noreply@devexpress.com", siteFont,
            Brushes.Black, rect, outStringFormat);
    }

    // Prohibiting default painting.
    e.Handled = true;
}

private void navBarGroup2_CalcGroupClientHeight(object sender, 
  NavBarCalcGroupClientHeightEventArgs e) {
   e.Height = 70;        
}
See Also