英語で読む

次の方法で共有


How to: Implement the Find and Replace Mechanism

Visual Studio provides two ways of implementing Find/Replace. One way is to pass a text image to the shell and let it handle searching, highlighting, and replacing text. This allows users to specify multiple text spans. Alternatively, your VSPackage can control this functionality itself. In both cases you must notify the shell about the current target and the targets for all open documents.

To implement Find/Replace

  1. Implement the IVsFindTarget interface on one of the objects returned by the frame properties VSFPROPID_DocView or VSFPROPID_DocData. If you are creating a custom editor, you should implement this interface as part of the custom editor class.

  2. Use the GetCapabilities method to specify the options that your editor supports and to indicate whether it implements text image searching.

    If your editor supports text image searching, implement GetSearchImage.

    Otherwise, implement Find and Replace.

  3. If you implement the Find and Replace methods, you can simplify your searching tasks by calling the IVsFindHelper interface.

See Also

Reference

IVsFindHelper

IVsFindTarget

Find

GetSearchImage

Replace

__VSPROPID