I am trying to remove the newline and replace with whitespace before pasting to comboBox as it ignores anything beyond a line. I am trying this:
If e.Modifiers = Keys.Control AndAlso e.KeyValue = Keys.V Then Then
Clipboard.SetText(Regex.Replace(Clipboard.GetText(TextDataFormat.UnicodeText), "\n", " "))
e.Handled = True
End If
I am performing this inside KeyDown event but it is able to capture either Ctrl or V but not both. I tried Capture CTRL+V or paste in a textbox in .NET and http://social.msdn.microsoft.com/Forums/windows/en-US/096540f4-4ad4-4d24-ae12-cfb3e1b246f3/interceptingoverriding-paste-behavior-on-combobox but no results as desired. May be there is something i am missing in my code. Please help me out.
I am getting the needed value with this Clipboard.GetText().Replace(vbCrLf, " ") when i debug but i am not able to set it. I tried using a variable to set it but even then no change. I also tried clearing the clipboard and then resetting with this variable holding the modified value.
I am using Winforms and i tried this but still no change to my clipboard:
Private Const WM_PASTE As Integer = &H302
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_PASTE Then
Dim returnText As String = Nothing
If (Clipboard.ContainsText()) Then
returnText = Clipboard.GetText().Replace(vbCrLf, " ")
Clipboard.Clear()
Clipboard.SetText(returnText)
End If
End If
MyBase.WndProc(m)
End Sub