Choose the part of the default behavior of double-clicking a text box. I want to override it with choosing a word. But in order to handle doubleclick events (or override onDoubleClick method), I had to actually do the default behavior, then execute my code. It is possible to disable default behavior.
It does not appear that you can do this with standard WinForms event handler ( DoubleClick
and MouseDoubleClick
do not give you any way to suppress the default behavior), but you have to deal with a custom WndProc
and window messages automatically.
In the example below, I am creating in the PreviewTextBox
class. I expose the PreviewDoubleClick
event via this class, which is handled in the client code, using e.Handled = true;
can be set to suppress the default double-click behavior. In this example, the event is controlled in the onpreview doubleclick
event handler, where you can add your custom code to respond to double click as you wish.
If you need additional mouse information about double click, I believe you can get it through the WndProc
/ field. (The code below assumes that you already have some code for the form setup)
using the system; Using System.Windows.Forms; Namespace WindowsFormsApplication2 {class DoubleClickEventArgs: EventArgs {public bool handle {get; Set; }} Class PreviewTextbox: Textbox {public event event handler
Comments
Post a Comment