Skip to content
Steve Towner edited this page May 7, 2016 · 6 revisions

Welcome to the ScintillaNET-FindReplaceDialog wiki!

Features

###Find Dialog Find Dialog

###Replace Dialog Replace Dialog

###Find/Replace Dialog Options Show recent search history: Find History

Show and add extended search parameters: Extended Search Helper

Show and add regular expression parameters: Search Helper

###Incremental Search Incremental Search

The incremental serach toolbar can be displayed in two ways: ####ToolStrip Style In this case, the search bar can be embedded in a ToolStrip or placed directly on a form allowing access to the search bar without using a keyboard shortcut. ToolStrip Style Incremental Search ####In Editor Style In this case, the search bar will appear on demand (using a keyboard shortcut) and appears over the ScintillaNET control. The search bar can optionally switch sides of the ScintillaNET control depending on the caret position. Navigating away from the search bar makes it disappear. Editor Style Incremental-Search

Go To Dialog

Go To Line Dialog

Usage

Here are some examples how to integrate with ScintillaNET. For all steps, you will need to:

  1. Add a reference to the binary output of this project (the .dll).
  2. Add the following to the top of the file in which you will be using the library:
using ScintillaNET_FindReplaceDialog;

###Find & Replace Dialog

The following declares an instance of FindReplace globablly with reference to a ScintillaNET control.

    public partial class Form1 : Form
    {
    	// Declare variable for FindReplace dialog
        FindReplace MyFindReplace;

        public Form1()
        {
            InitializeComponent();

            // Create instance of FindReplace with reference to a ScintillaNET control.
            MyFindReplace = new FindReplace(scintilla1);
        }

		private void FindButton_Click(object sender, EventArgs e)
		{
			MyGoTo.ShowFind();
		}

		private void ReplaceButton_Click(object sender, EventArgs e)
		{
			MyGoTo.ShowReplace();
		}
	}

###Go To Dialog The following creates and shows a Go To dialog. Once the user enters a line number, the referenced ScintillaNET control will go to that location, the form will close. The Go To instance is no longer required.

	private void GotoButton_Click(object sender, EventArgs e)
	{
		GoTo MyGoTo = new GoTo(scintilla1);
		MyGoTo.ShowGoToDialog();
	}

###Incremental Search The Incremental Search control is a component of the FindReplace class and as such, creating an instance of the FindReplace class gives the ability to show the Incremental Search control within the ScintillaNET control (actually infront of it). All that is required is to call the specific method to show the control as below.

	MyFindReplace.ShowIncrementalSearch();

Optionally the control can be dropped onto a form (in this case named 'incrementalSearcher1' and hooked directly to a FindReplace instance as shown below. In this case, the control is always visible, so a call to 'ShowIncrementalSearch' is not required.

    public partial class Form1 : Form
    {
    	// Declare variable for FindReplace dialog
        FindReplace MyFindReplace;

		public Form1()
        {
            InitializeComponent();

			MyFindReplace = new FindReplace(scintilla1);
			incrementalSearcher1.FindReplace = MyFindReplace;
        }
	}

###Keyboard Shortcuts It is handy to unclude keyboard shortcuts normally used in text editors. In the example below, the KeyDown event of a ScintillaNET control is used. If a keypress is used, it is suppressed, preventing ScintillaNET from receiving and displaying the character.

The following shortcuts are used:

  • CTRL+F - Show Find Dialog
  • CTRL+H - Show Replace Dialog
  • CTRL+I - Show Incremental Find Control
  • CTRL+G - Show Go To Dialog
	private void scintilla1_KeyDown(object sender, KeyEventArgs e)
	{
		if (e.Control && e.KeyCode == Keys.F)
		{
			MyFindReplace.ShowFind();
			e.SuppressKeyPress = true;
		}
		else if (e.Control && e.KeyCode == Keys.H)
		{
			MyFindReplace.ShowReplace();
			e.SuppressKeyPress = true;
		}
		else if (e.Control && e.KeyCode == Keys.I)
		{
			MyFindReplace.ShowIncrementalSearch();
			e.SuppressKeyPress = true;
		}
		else if (e.Control && e.KeyCode == Keys.G)
		{
			GoTo MyGoTo = new GoTo(scintilla1);
			MyGoTo.ShowGoToDialog();
			e.SuppressKeyPress = true;
		}
	}

Clone this wiki locally