Articles in this section
Category / Section

How to show tooltip for the tab header in WinForms TabbedMDIManager?

2 mins read

Tooltip

We can set tooltip text for header of tab items in the TabbedMDIManager on MouseMouse of TabControl. It can be achieved by SetToolTip method based on the mouse position and tab bounds. The following code demonstrates the same.

C#

//Initialize
Form2 f1 = new Form2();
Form3 f2 = new Form3();
Form4 f3 = new Form4();
 
TabControlAdv tabcontrol;
tabbedMDIManager1.TabControlAdded += TabbedMDIManager1_TabControlAdded;
 
//TabStyle
tabbedMDIManager1.TabStyle = typeof(Syncfusion.Windows.Forms.Tools.TabRendererWorkbookMode);
 
//For MDI Forms
f1.MdiParent = this;
f1.Show();
f2.MdiParent = this;
f2.Show();
f3.MdiParent = this;
f3.Show();
 
private void TabbedMDIManager1_TabControlAdded(object sender, Syncfusion.Windows.Forms.Tools.TabbedMDITabControlEventArgs args)
{
  tabcontrol = args.TabControl;
  tabcontrol.ActiveTabColor = Color.Green;
  tabcontrol.ActiveTabForeColor = Color.White;
  tabcontrol.InactiveTabColor = Color.Brown;
  tabcontrol.InActiveTabForeColor = Color.Yellow;
  tabcontrol.TabPanelBackColor = Color.LightGray;
  tabcontrol.ItemSize = new Size(30, 30);
  if(tabcontrol != null)
  {
    //For Tooltip
    tabcontrol.MouseMove += Tabcontrol_MouseMove;
  }
}
 
private void Tabcontrol_MouseMove(object sender, MouseEventArgs e)
{
  for (int i = 0; i < tabcontrol.TabPages.Count; i++)
  {
    Rectangle r = tabcontrol.GetTabRect(i);
    if (r.Contains(e.Location) && toolTip1.GetToolTip(tabcontrol).ToString() != tabcontrol.TabPages[i].Text)
    {
      //Set ToolTip Text
      toolTip1.SetToolTip(tabcontrol, tabcontrol.TabPages[i].Text);
      break;
    }
  }
}

VB

'Initialize 
Private f1 As New Form2()
Private f2 As New Form3()
Private f3 As New Form4()
 
Private tabcontrol As TabControlAdv
AddHandler tabbedMDIManager1.TabControlAdded, AddressOf TabbedMDIManager1_TabControlAdded
 
'TabStyle
tabbedMDIManager1.TabStyle = GetType(Syncfusion.Windows.Forms.Tools.TabRendererWorkbookMode)
 
'For MDI Forms
f1.MdiParent = Me
f1.Show()
f2.MdiParent = Me
f2.Show()
f3.MdiParent = Me
f3.Show()
 
Private Sub TabbedMDIManager1_TabControlAdded(ByVal sender As Object, ByVal args As Syncfusion.Windows.Forms.Tools.TabbedMDITabControlEventArgs)
  tabcontrol = args.TabControl
  tabcontrol.ActiveTabColor = Color.Green
  tabcontrol.ActiveTabForeColor = Color.White
  tabcontrol.InactiveTabColor = Color.Brown
  tabcontrol.InActiveTabForeColor = Color.Yellow
  tabcontrol.TabPanelBackColor = Color.LightGray
  tabcontrol.ItemSize = New Size(30, 30)
  If tabcontrol IsNot Nothing Then
    'For Tooltip
    AddHandler tabcontrol.MouseMove, AddressOf Tabcontrol_MouseMove
  End If
End Sub
 
Private Sub Tabcontrol_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
  For i As Integer = 0 To tabcontrol.TabPages.Count - 1
    Dim r As Rectangle = tabcontrol.GetTabRect(i)
    If r.Contains(e.Location) AndAlso toolTip1.GetToolTip(tabcontrol).ToString() <> 
tabcontrol.TabPages(i).Text Then
      'Set ToolTip Text
      toolTip1.SetToolTip(tabcontrol, tabcontrol.TabPages(i).Text)
      Exit For
    End If
  Next i
End Sub

 

Screenshot

Show tooltip hover on the tab header in TabbedMDIManager

 

Samples:

C#:  TabbedMDIManagerSample

VB: TabbedMDIManagerSample

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied