I want to remove the flashing dash from a TextBox when the user presses it and to stop the user from being give the option to select and copy text.
Is this possible?
Depending on what you need exactly, there are many ways you can achieve this.
Call Clipboard.SetText("") whenever GotFocus and LostFocus events are triggered.
Override SelectionChanged and do e.Handled = true.
Create your own custom control by inheriting TextBox, set a custom Template, and manually add/remove characters for every KeyDown event.
There doesn't seem to be a way to change the flashing caret/cursor on Windows Universal apps, and there is no way to disable the clipboard either.
Related
Is there any way to catch the Up/Down arrow keys in a WPF TextBox (System.Windows.Controls.Textbox) and allow them to alter the text? I've read about overiding the ProcessCmdKey method for a Windows Forms TextBox (System.Windows.Forms.TextBox), and it worked fine, but that TextBox is not nearly as flexible as the WPF one. Is there a similar method to accomplish this without having to use the old Windows Forms TextBox?
For my example, I have a TextBox that has a numeric text-mask. I want to be able increase/decrease the numeric value by using the up and down arrow keys.
You could add event handlers to KeyUp and/or KeyDown, if that doesn't get what you need, using PreviewKeyUp and/or PreviewKeyDown should.
I use standart TextBox in my windows universal app. When I enter text to TextBox
appears button delete.
I need a press event to button delete. It should simply be, but I found nothing. Or do I just go to sleep :)
update:
I solved this problem by binding properties of the text.
I'm using Windows.UI.Xaml.Controls.TextBox developing Universal Windows App. When text box is enabled GotFocus event normally fired. Otherwise when it is disabled I can't detect user interactions with it. Somehow I need to know that user is trying to access the text box and notify him why he can't do so. Also I have tried to use Tapped event - no success.
A disabled textbox won't fire the GotFocus event (or any other events, from what I can see).
Consider setting the IsReadOnly property to true instead of disabling the whole element. Then events will still be able to fire.
I am using a textbox in winform (c#) and using the text to make consults in a database.
But I need constantly consult the text of the textbox every time that text changes. So for these, I use the KeyUp. But this event is too slow.
Is any event that just fires when the textbox editing has been finished ?. I consider for finish 2 conditions
The control lost focus.
The control has 200ms without keypress
You could use the LostFocus event, to capture when the user clicks on a control outside the textbox.
Otherwise, you'll need to choose from one of the existing events. (Listed here)
Come to think of it, you will likely have to capture multiple events. DragDrop if someone copies/pastes, for example...
You mean something like this?
Control.LostFocus
Provided that you consider finished as being when they click off the textbox.
I'm wondering how to filter the input of a .NET textbox.
I already know that I could listen for the KeyDown event and intercept the key, but that won't filter pasted strings by a right-click menu or a CTRL+V.
I also don't wan't to completely disable the possibility of pasting of characters in the textbox. The paste action should be cancelled whenever it contains one or more invalid characters.
Finally, I'd like to display a notification balloon whenever invalid characters are either entered or pasted.
μTorrent already has this exact behavior:
How can I achieve this functionality in C# ?
TextChanged event - Seems like a good call.
You can spawn your own baloon or ToolTip on any control you want to show a detailed feedback to the user
It seems like a combination of KeyPress, TextChanged, Validating, and Validated events should work for your purposes.