Articles in this section
Category / Section

How to disable the LabelEdit functionality in a particular TabPageAdv based on its text in WinForms TabControlAdv?

1 min read

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.


//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");


'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


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