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. Image for the cookie policy date

Can I Add Custom Controls Like button or DropDown etc on Tab

hi,

I am looking a Tab to have a Custom Controls like a close button on active tab or may be all tabs can TabbedDocking Manager Do that?

thanks

This is what I am looking for

1 Reply

AJ Ashwini Jaya Preetha Durai Samy Syncfusion Team September 7, 2015 12:05 PM UTC

Hi Trushar,

Thank you for using Syncfusion products.

At present we do not have direct support to achieve the requirement for adding custom control in TabControlAdv or TabbedMDIManager. But this can be achieved by handling the DrawItem event in TabControlAdv. Please refer the below code snippet.

Code snippet [VB]:


'DrawItem event of TabControlAdv

              Private Sub tabControlAdv1_DrawItem(ByVal sender As Object, ByVal drawItemInfo As Syncfusion.Windows.Forms.Tools.DrawTabEventArgs)


                     Dim lgb As LinearGradientBrush

                     ' Use LinearGradientBrush to set gradient.

                     ' Use GetTabRect to get the rectangle of the tabs.

                     If drawItemInfo.Index <> Me.tabControlAdv1.SelectedIndex Then

                           ' For the non-selected tabs

                           lgb = New System.Drawing.Drawing2D.LinearGradientBrush(Me.tabControlAdv1.GetTabRect(drawItemInfo.Index), Color.FromArgb(197, 197, 173), Color.FromArgb(228, 228, 212), LinearGradientMode.Horizontal)

                     Else

                           ' For the selected tab

                           lgb = New System.Drawing.Drawing2D.LinearGradientBrush(Me.tabControlAdv1.GetTabRect(drawItemInfo.Index), Color.White, Color.WhiteSmoke, LinearGradientMode.Horizontal)

                     End If

                     Dim positions() As Single = { 0.0f, 0.05f, 0.95f, 1.0f }

                     Dim factors() As Single = { 0.4f, 1.0f, 0.05f, 0.04f }

                     ' Blend settings

                     Dim blend As New Blend()

                     blend.Factors = factors

                     blend.Positions = positions

                     lgb.Blend = blend

                     drawItemInfo.Graphics.FillRectangle(lgb, Me.tabControlAdv1.GetTabRect(drawItemInfo.Index))

                     lgb.Dispose()

                     ' Draw the default borders and interior (text and image)

                     drawItemInfo.DrawBorders()




                     drawItemInfo.Graphics.DrawString(Me.tabControlAdv1.TabPages(drawItemInfo.Index).Text, drawItemInfo.Font, Brushes.Black, drawItemInfo.Bounds.X + 5, drawItemInfo.Bounds.Y + 5)

                     CloseButton = New Rectangle(drawItemInfo.Bounds.X + drawItemInfo.Bounds.Width - 15, drawItemInfo.Bounds.Y + 6, 10, 10)

                     drawItemInfo.Graphics.DrawLine(New Pen(Brushes.Black), New Point(CloseButton.X,CloseButton.Y), New Point(CloseButton.X+ CloseButton.Width, CloseButton.Y+CloseButton.Height))

                     drawItemInfo.Graphics.DrawLine(New Pen(Brushes.Black), New Point(CloseButton.X, CloseButton.Y+CloseButton.Height), New Point(CloseButton.X + CloseButton.Width, CloseButton.Y))

                     drawItemInfo.Graphics.DrawRectangle(New Pen(Brushes.Black), CloseButton)
              End Sub


We have also prepared a sample for TabbedMDIManager and TabControlAdv and it can be downloaded from the following location.

TabControlAdv Sample:  https://www.syncfusion.com/downloads/support/forum/120146/ze/TabControlAdvSampleVB1791071414

TabbedMDIManager Sample: https://www.syncfusion.com/downloads/support/forum/120146/ze/TabbedMDISampleVB2070263994

Please look into the sample and kindly let us know if it helps. If not please provide us more information about your like screen shot. That will be helpful for us to analyze and provide you the prompt solution as earlier as possible.

Please let us know if you need any further assistance,

Regards,
Ashwini

Loader.
Live Chat Icon For mobile
Up arrow icon