)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the close button of the individual MDI child in WinForms TabbedGroupedMDIManager?

Platform: WinForms |
Control: TabbedGroupedMDIManager |
Published Date: April 30, 2011 |
Last Revised Date: January 27, 2020

Customize the close button of specific MDI child

We can customize the size of the close button of the individual MDI child in TabbedGroupedMDIManager by deriving it's tab style renderer and overriding GetCloseButtonBounds() method

C#

//Rendering TabRendererOffice2007 since the TabbedGroupedMDIManager's 
//tabstyle is set as TabRendererOffice2007.
public class TabRendererMSOffice2007 : TabRendererOffice2007
{
   static TabUIDefaultProperties tabPanelPropertyExtender;
   // Exposes the default appearance properties to the tab panel renderer.
   public static new TabUIDefaultProperties TabPanelPropertyExtender
   {
       get { return tabPanelPropertyExtender; }
   }
   // Specifies the name by which this renderer will be identified.
   public static new string TabStyleName
   {
       get { return "MSOffice2007"; }
   }
   static TabRendererMSOffice2007()
   {
      tabPanelPropertyExtender = new TabUIDefaultProperties();
      TabRendererFactory.RegisterTabType(TabStyleName, typeof(TabRendererMSOffice2007), TabPanelPropertyExtender);
   }
   public TabRendererMSOffice2007(ITabControl parent, ITabPanelRenderer panelRenderer) : base(parent, panelRenderer)
   { }
   protected override RectangleF GetCloseButtonBounds(DrawTabEventArgs drawItemInfo)
   {
       // Get the close button bounds and change the size, as needed.
       RectangleF rect = base.GetCloseButtonBounds(drawItemInfo);
       rect.Width = 10;
       rect.Height = 10;
       return rect;
   }
}

VB

'Rendering TabRendererOffice2007 since the TabbedGroupedMDIManager's 
'tabstyle is set as TabRendererOffice2007.
Public Class TabRendererMSOffice2007
    Inherits TabRendererOffice2007
    Private Shared tabPanelPropertyExtender_Renamed As TabUIDefaultProperties
    ' Exposes the default appearance properties to the tab panel renderer.
    Public Shared Shadows ReadOnly Property TabPanelPropertyExtender() As TabUIDefaultProperties
        Get
             Return tabPanelPropertyExtender_Renamed
        End Get
    End Property
    ' Specifies the name by which this renderer will be identified.
    Public Shared Shadows ReadOnly Property TabStyleName() As String
        Get
             Return "MSOffice2007"
        End Get
    End Property
    Shared Sub New()
        tabPanelPropertyExtender_Renamed = New TabUIDefaultProperties()
        TabRendererFactory.RegisterTabType(TabStyleName, GetType(TabRendererMSOffice2007), TabPanelPropertyExtender)
    End Sub
    Public Sub New(ByVal parent As ITabControl, ByVal panelRenderer As ITabPanelRenderer)
       MyBase.New(parent, panelRenderer)
    End Sub
    Protected Overrides Function GetCloseButtonBounds(ByVal drawItemInfo As DrawTabEventArgs) As RectangleF
        'Get the close button bounds and change the size, as needed.
        Dim rect As RectangleF = MyBase.GetCloseButtonBounds(drawItemInfo)
        rect.Width = 10
        rect.Height = 10
        Return rect
    End Function
End Class

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon