CoreWebView2Find Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Interface providing methods and properties for finding and navigating through text in the web view. This interface allows for finding text, navigation between matches, and customization of the find UI.
public class CoreWebView2Find
type CoreWebView2Find = class
Public Class CoreWebView2Find
- Inheritance
-
CoreWebView2Find
Properties
ActiveMatchIndex |
Retrieves the index of the currently active match in the find session. Returns the index of the currently active match, or -1 if there is no active match. The index starts at 1 for the first match. |
MatchCount |
Gets the total count of matches found in the current document based on the last find sessions criteria. Returns the total count of matches. |
Methods
FindNext() |
Navigates to the next match in the document. If there are no matches to find, FindNext will wrap around to the first match's index. If called when there is no find session active, FindPrevious will silently fail. |
FindPrevious() |
Navigates to the previous match in the document. If there are no matches to find, FindPrevious will wrap around to the last match's index. If called when there is no find session active, FindPrevious will silently fail. |
StartAsync(CoreWebView2FindOptions) |
Initiates a find using the specified find options asynchronously.
Displays the Find bar and starts the find session. If a find session was already ongoing, it will be stopped and replaced with this new instance.
If called with an empty string, the Find bar is displayed but no finding occurs. Changing the FindOptions object after initiation won't affect the ongoing find session.
To change the ongoing find session, Start must be called again with a new or modified FindOptions object.
Start supports HTML and TXT document queries. In general, this API is designed for text-based find sessions.
If you start a find session programmatically on another file format that doesn't have text fields, the find session will try to execute but will fail to find any matches. (It will silently fail)
Note: The asynchronous action completes when the UI has been displayed with the find term in the UI bar, and the matches have populated on the counter on the find bar.
There may be a slight latency between the UI display and the matches populating in the counter.
The MatchCountChanged and ActiveMatchIndexChanged events are only raised after Start has completed; otherwise, they will have their default values (-1 for active match index and 0 for match count).
To start a new find session (beginning the search from the first match), call |
Stop() |
Stops the current 'Find' session and hides the Find bar. If called with no Find session active, it will silently do nothing. |
Events
ActiveMatchIndexChanged |
Registers an event handler for the ActiveMatchIndexChanged event. This event is raised when the index of the currently active match changes. This can happen when the user navigates to a different match or when the active match is changed programmatically. The parameter is the event handler to be added. Returns a token representing the added event handler. This token can be used to unregister the event handler. |
MatchCountChanged |
Registers an event handler for the MatchCountChanged event. This event is raised when the total count of matches in the document changes due to a new find session or changes in the document. The parameter is the event handler to be added. Returns a token representing the added event handler. This token can be used to unregister the event handler. |