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.
Related
Is there a way to send message (like mousedown) to a control?
My purpose is that when you click GridView, prevent mousedown behavior itself and bypass mousedown message to RepositoryItem.
From your question: "My purpose is that when you click GridView, prevent mousedown behavior itself and bypass mousedown message to RepositoryItem."
It sounds like you want to control the behavior of the Mouse Down event on the control. Right?
If that's the case, on the Winforms designer, look at the properties panel. On there is also a selection for the form events for a control. You can scroll down and find the Mouse Down event and add an event handler. Then do whatever filtering you need including not even processing the message at all.
You also mentioned that it's a DevExpress control. I recall that some of their controls were wired up a little differently so the DevExpress website might have some additional clues.
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.
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 re-writing the C# DateTimePicker (nullable) to fit my needs, but I'm stuck at detecting the up-down events from picking time (HH:mm, DateTimePicker.ShowUpDown = true).
I am aware that the OnValueChanged is fired when the either the up or down button is pressed, but I already have some handling there (move to next field automatically when a number is typed in to the DateTimePicker), and therefor I need to block the ValueChanged event when those buttons are pressed, and handle it in a different function.
I'm trying to override the WndProc function, but OnValueChanged are called before WndProc. OnKeyDown is also called after OnValueChanged.
Any ideas?
Well you could try overriding OnDropDown which occurs whenever the drop down calender is requested.
You should not block ValueChanged event, when value of DateTimePicker is changed. And Up Down buttons are used for changing DateTimePicker value, thus pressing them should raise ValueChanged event.
Consider to change your current handling of this event.
BTW Why are you navigating to next field when value changed? Just assign appropriate TabIndex values to your controls and allow user to use Tab button for navigation to next field. This is a common approach for navigation.
I am using maskedTextBox.SelectAll() to highlight the text in the MaskedTextBox in the Enter and MouseDown events.
It works when I use the mouse, but I go to that textbox by pressing the Tab key, it does not work.
What am I missing here?
Have you tried the GotFocus event?
When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on), by calling the Select or SelectNextControl methods, or by setting the ContainerControl.ActiveControl property to the current form, focus events occur in the following order:
It then goes on to list the events that are fired. It looks like this fires when the mouse is used so you might only need this handler.