Delete Functionality in RichtextBox (Windows Forms with .NET 3.5) - winforms

I am facing a problem to implement the delete functionality. The Key_Down event is not getting raised when I pressed a delete key from Keyboard. If I implement the Key_Press OR Key_Up Event.
Suppose I have selected some Text from RichTextBox and pressed the DEL, then the text get removed first and then it reaches to the Event code(Key_Press OR Key_Up Event).
Can anybody help me to resolved this?

If you are trying to check for the delete key you could try the KeyPreview event. That should fire before the KeyPress or KeyDown events.

Related

NumericUpDown ValueChanged event not working on entering values

Event not activates on entering values by using numbers on keyboard. It only activates when you use the up and down arrows. What I want is, It must activate on every keyboard stroke like textbox textchanged event.
I've tried few things but user had to press enter for activating the event. I don't want that.
It must be same like textbox event. Any ideas ? or another tool maybe ?
NumericUpDown control fires the value changed event in the following scenarios
When using Up/Down arrows of the control as you have mentioned.
When the control loses focus after changing the value using keyboard input.
When using Up/Down arrow keys in the keyboard.
Instead of ValueChanged you can use KeyPress event which fires for every keyboard key stroke.(but keep in mind this event will only fire for keyboard numeric key press)
private void numericUpDown1_KeyPress(object sender, KeyPressEventArgs e)
{
}

WPF: TextBox do not paste text on KeyDown (CTRL+V) event

We have a WPF window hosted in Win32 Window. The implementation is such that when user presses CTRL+V, the text in clipboard is pasted to the TextBox in KeyUp event and not in KeyDown event (due to limitation with TextBox control when being hosted inside MFC). Hence we have overridden KeyUp event to paste the text.
However, in some machines it was noticed that the text is pasted twice on doing CTRL+V only once. On further investigation found that it is pasted for KeyDown (default window behaviour) and also on KeyUp event (overridden by us).
Wondering why is it pasting only on KeyUp even in some machine and in some machine for both KeyDown and KeyUp?
Help will be appreciated.
-Nayan
I think it would depend on which control has the focus when you press CTRL+V.
If the edit control has the focus, it would get a WM_PASTE notification and the default WindowProc will paste the clipboard contents into the text box.
If another control has the focus, you'll need to handle CTRL+V yourself to paste into the edit control.

WPF: Prevent Combobox from Swallowing Keydown Event

So I have a window that handles the KeyDown event. Everything works as expected except under two conditions:
The up / down arrow keys are pressed and
A combo box on the window has more than one item.
Even if I've never clicked on the combo box it doesn't seem to matter. The SelectionChanged event on the combobox fires before the Window even fires its KeyDown event. This seems highly counter-intuitive to me.
I don't know enough about WPF event propagation to even know where to start looking for a solution. Any recommendations?
You should subscribe to PreviewKeyDown event instead.

How to handle window keydown event when it contain previewkeydown event of textbox?

My application have custom image control,button and a custom textbox.I implemented some key operations in window keydown event belonging to image and some key operations in textbox previewkeydown event.When the focus is on image or button,key operations of the window works well.When the focus is on the textbox,combination of two key operations doesn't work well.For example,when the focus is on textbox,if I pressed ctrl + up arrow,first it fires the keydown event of both textbox and window keydown event where e.key contain ctrl.second textbox's keydown event is fired but windows keydown event is not fired why..?
Might input binding help you out?
See: http://www.switchonthecode.com/tutorials/wpf-tutorial-command-bindings-and-custom-commands
Its what's used for keyboard input in WPF way more than the KeyDown and KeyUp events. I'm having my own issues with those right now, ugh.

wpf label, access key, event

When using a WPF label as a keyboard shortcut mechanism, is there an event fired for this?
and 2 minutes later I actually find this:
AccessKeyManager.AccessKeyPressed

Resources