How can be selected text in a TextBox deleted by issuing some TextBox class method or property? The goal of the deletion is that it can be undone. I have tryed to delete text with textBox.SelectedText = "", which functions as it can be expected, but can not be undoned.What is interesting, is that it functions well with RichTextBox control. Regards, Predrag.
.NET doesn't have a built in way of doing that.
You'll have to use PInvoke:
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(System.IntPtr hWnd, int msg, int
lParam, int wParam);
private const int WM_CLEAR = 0x0303;
...
SendMessage(myTextBox.Handle, WM_CLEAR, 0, 0);
/claes
> How can be selected text in a TextBox deleted by issuing some TextBox class method or property? The goal of the deletion is that it can be undone.
I have tryed to delete text with textBox.SelectedText = "", which functions
as it can be expected, but can not be undoned.What is interesting, is that
it functions well with RichTextBox control. Regards, Predrag.
> ---
> Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
Predrag Rakic - 14 Jan 2005 12:37 GMT
Hi Claes, undo delete in TextBox control works fine. Thanks, Predrag.