)
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 disable the LabelEdit functionality in a particular TabPageAdv based on its text in WinForms TabControlAdv?

Platform: WinForms |
Control: TabControlAdv |
Published Date: April 13, 2015 |
Last Revised Date: January 31, 2020

Disable the label edit functionality

The LabelEdit functionality can be disabled for a particular TabPageAdv based on its text by handling the MouseDown and LabelEditTextChanged events in the TabControlAdv. The following code example demonstrates the same.

C#

//Handles the MouseDown event.
private void tabControlAdv1_MouseDown(object sender, MouseEventArgs e)
{
   if(e.Clicks == 2)
   {
     //Gets the selected tabpage text.
     SelectedTabPageText = this.tabControlAdv1.SelectedTab.Text;
   }
}
//Validates the renamed text of the SelectedTab.
private void tabControlAdv1_LabelEditTextChanged(object sender, EventArgs e)
{
   if(this.tabControlAdv1.SelectedTab.Text != SelectedTabPageText)
   {
     //Resets the text of the tabpage.
     this.tabControlAdv1.SelectedTab.Text = SelectedTabPageText;
     MessageBox.Show("Invalid TabPage name");
   }
}

VB

'Handles the MouseDown event.
Private Sub tabControlAdv1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles tabControlAdv1.MouseDown
   If e.Clicks = 2 Then
     'Gets the selected tabpage text
     SelectedTabPageText = Me.tabControlAdv1.SelectedTab.Text
   End If
End Sub
'Validates the renamed text of the SelectedTab.
Private Sub tabControlAdv1_LabelEditTextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles tabControlAdv1.LabelEditTextChanged
   If Me.tabControlAdv1.SelectedTab.Text <> SelectedTabPageText Then
     'Resets the text of the tabpage.
     Me.tabControlAdv1.SelectedTab.Text = SelectedTabPageText
     MessageBox.Show("Invalid TabPage name ")
   End If
End Sub

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ValidatePabPageText882471564.zip

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