Articles in this section
Category / Section

How to customize the controls on the Configuration Editor dialog in WinForms SyntaxEditor (EditControl)?

1 min read

Show or hide tab pages and rename buttons

You could selectively show or hide the TabPages and rename the Buttons on the Configuration Editor dialog as shown in the method below.

C#

private frmConfigDialog CustomizeConfigDialog (frmConfigDialog form)
{
    foreach (Control ctrl in form.Controls)
    {
       if (ctrl is Button)
       {
           Button btn = (Button) ctrl;
           if (btn.Text == "&OK")
               btn.Text = "&Apply";
       }
       // Get the TabControl in the ConfigDialog form
       else if (ctrl is TabControl)
       {
           TabControl tabControl = (TabControl) ctrl;
           TabPage formatsPage = null;
           // Get the Formats TabPage
           foreach (TabPage page in tabControl.TabPages)
           {
                if (page.Text == "Formats")
                   formatsPage = page;
           }
           // Clear all TabPages in the TabControl
           tabControl.TabPages.Clear();
           // Add only the Formats TabPage
           tabControl.TabPages.Add(formatsPage);
       }
    }
    return (frmConfigDialog) form;
}

 

VB

Private Function CustomizeConfigDialog(form As frmConfigDialog) As frmConfigDialog
    Dim ctrl As Control
    For Each ctrl In form.Controls
        If TypeOf ctrl Is Button Then
           Dim btn As Button = CType(ctrl, Button)
           If btn.Text = "&OK" Then
              btn.Text = "&Apply"
           End If
           ' Get the TabControl in the ConfigDialog form
           ElseIf TypeOf ctrl Is TabControl Then
              Dim tabControl As TabControl = CType(ctrl, TabControl)
              Dim formatsPage As TabPage = Nothing
               ' Get the Formats TabPage
              Dim page As TabPage
              For Each page In tabControl.TabPages
                 If page.Text = "Formats" Then
                    formatsPage = page
                 End If
              Next page ' Clear all TabPages in the TabControl
              tabControl.TabPages.Clear()
              ' Add only the Formats TabPage
              tabControl.TabPages.Add(formatsPage)
           End If
    Next ctrl
    Return CType(form, frmConfigDialog)
End Function 'CustomizeConfigDialog

 

 

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