[]
        
(Showing Draft Content)

Using a Custom Dialog Box

There may be instances where you want to use your own custom version of the built-in C1Editor dialog boxes. This can easily be done with the CustomDialogs property.

First implement the custom dialog box and make sure it supports the appropriate interface, IFindReplaceDialog for a custom Find and Replace dialog box, for example.

In this example, we'll assume you have created three custom dialog boxes: BookmarkDialog, FindReplaceDialog, and FormattingDialog.

Add the following code to your project to set the CustomDialogs property.

To write code in C#

private void InitCustomDialogs()
        {
            editor.CustomDialogs.BookmarkDialog = new BookmarkEditorForm();
            editor.CustomDialogs.FindReplaceDialog = new FindReplaceForm();
            editor.CustomDialogs.FormattingDialog = new FormattingForm();
        }

Then you can use the ShowDialog method to open each new dialog box. In this example, we have a toolStrip with three buttons that, when clicked, open the custom dialog boxes.

To write code in C#

private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            // opens the Bookmark dialog box
            if (e.ClickedItem == buttonBookmark)
               editor.ShowDialog(C1.Win.Editor.DialogType.Bookmark);
            // opens the Find dialog box
            else if (e.ClickedItem == buttonFind)
               editor.ShowDialog(C1.Win.Editor.DialogType.Find);
            // opens the Formatting dialog box
            else if (e.ClickedItem == buttonFormatting)
               editor.ShowDialog(C1.Win.Editor.DialogType.Format);
        }

For a detailed example on creating and using custom dialog boxes, see the Custom Dialogs sample installed with the product.