ComponentOne XmlEditor for WinForms: C1XmlEditor Run-Time Elements > C1XmlEditor Dialog Boxes > Using a Custom Dialog Box

Using a Custom Dialog Box

There may be instances where you want to use your own custom version of the built-in C1XmlEditor 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.

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.

private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)

        {

            // opens the Bookmark dialog box

            if (e.ClickedItem == buttonBookmark)

               editor.ShowDialog(C1.Win.XmlEditor.DialogType.Bookmark);

            // opens the Find dialog box

            else if (e.ClickedItem == buttonFind)

               editor.ShowDialog(C1.Win.XmlEditor.DialogType.Find);

            // opens the Formatting dialog box

            else if (e.ClickedItem == buttonFormatting)

               editor.ShowDialog(C1.Win.XmlEditor.DialogType.Format);

        }

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


Send comments about this topic to ComponentOne.
Copyright © 1987-2009 ComponentOne LLC. All rights reserved.