473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

How to do Ctrl + Z?

In VB.net, you can Copy to Clipboard... and then Paste from Clipboard.

What I'd like to do is to do a CTRL + Z to do and 'undo'.

For example, if you have some date in Combobox1 and Copy it to Clipboard. You
can then Paste it to Combobox2. But in Combobox2, you can (via keyboard)
CTRL+Z and undo the paste.

How can you in VB.net?

Thanks

Bruce
Nov 20 '05 #1
11 14243
Hi Bruce,

Undo and Redo need a context. ComboBoxes and TextBoxes, etc - they all
have an Undo because editable controls do that kind of thing.

What do you want your Undo/Redo to work with?

The most general answer is that you must save the state of something before
an operation and swap the states when Undo is requested. (Swap - so that Undo
can undo the Undo). Multiple Undo requires the management of a stack of Undo
states.

Regards,
Fergus


Nov 20 '05 #2
* Mr. B <Us**@NoWhere.Com> scripsit:
In VB.net, you can Copy to Clipboard... and then Paste from Clipboard.

What I'd like to do is to do a CTRL + Z to do and 'undo'.

For example, if you have some date in Combobox1 and Copy it to Clipboard. You
can then Paste it to Combobox2. But in Combobox2, you can (via keyboard)
CTRL+Z and undo the paste.


In your own control? In your own form? You can define a menu with
theshowtcuts, like in:

<http://www.mvps.org/dotnet/dotnet/samples/controls/downloads/RichTextBoxContext.zip>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
With Deft Fingers, "Fergus Cooney" <fi****@post.com> wrote:
Hi Bruce,
Hullo Fergus.
What do you want your Undo/Redo to work with?
I sort of mentioned it in my original post. But here it is again:

You have a Combobox1 with some Text. A user cuts and pastes it into a 2nd
Combobox (2). Then they think.. hmmm... don't want to do that. So an 'undo'
would be nice.

Now... you can do the undo manually via the keyboard (CTRL+Z). Which is
really nothing more than the standard CTRL+Z that you can do in Windows (ie:
delete a file in File Explorer... press CTRL+Z and it will be restored from
Trashcan).
The most general answer is that you must save the state of something before
an operation and swap the states when Undo is requested. (Swap - so that Undo
can undo the Undo). Multiple Undo requires the management of a stack of Undo


Yeah. I was just hoping that an easier way was available. No big deal. Not
critical for my app... just was a thought.

Thanks!

Bruce
Nov 20 '05 #4
Hi Bruce,

You said it's not important - so don't answer if you don't want, but...

|| You have a Combobox1 with some Text. A user cuts and pastes it
|| into a 2nd Combobox (2). Then they think.. hmmm... don't want to
|| do that. So an 'undo' would be nice.
||
|| Now... you can do the undo manually via the keyboard (CTRL+Z).
|| Which is really nothing more than the standard CTRL+Z that you can
|| do in Windows

Like you say, you mentioned it in both posts, but what you've mentioned
is what already happens. Which is why I asked 'what do <you> want to do?'

In other words what are you going to be undoing and redoing? - because
the ComboBox one is already covered by Ctrl-Z, how can you improve it?

I'm just curious. ;-) (and I'm surely missing something).

Regards,
Fergus
Nov 20 '05 #5
With Deft Fingers, "Fergus Cooney" <fi****@post.com> wrote:
Hi Bruce,

You said it's not important - so don't answer if you don't want, but... In other words what are you going to be undoing and redoing? - because
the ComboBox one is already covered by Ctrl-Z, how can you improve it?


Because... not all Users are that smart (um... I mean... knowledgeable). And
(at least where I work) not many even 'know' about CTRL+Z... much less CTRL+C
or CTRL+V (grin)

So I'm working on the "make it damn Idiot proof" kinda level (:

So having 3 buttons for each (C, V, Z) is the target.

Regards,

Bruce
Nov 20 '05 #6
Hi Bruce,

Now I'm with you! :-)

One option is to put focus back to the Control and then
send it the appropriate key using SendKeys.

Regards,
Fergus
Nov 20 '05 #7
* "Mr. B" <Us**@NoWhere.Com> scripsit:
Because... not all Users are that smart (um... I mean... knowledgeable). And (at least where I work) not many even 'know' about CTRL+Z... much less CTRL+C or CTRL+V (grin)

So I'm working on the "make it damn Idiot proof" kinda level (:

So having 3 buttons for each (C, V, Z) is the target.


You may want to grab the handle of the textbox contained in the combobox and
use pinvoke on 'SendMessage' + 'EM_UNDO' and 'EM_REDO' (all code below
untested).

\\\
Public Const EM_UNDO As Int32 = &HC7
Public Const EM_REDO As Int32 = &HC7
///

You can use something like this to get the handle of the edit protion of the
combobox:

\\\
Private Declare Auto Function GetWindow Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal wCmd As Int32 _
) As IntPtr

Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32

Private Const EM_SETPASSWORDCHAR As Int32 = &HCC

Private Const GW_CHILD As Int32 = 5

Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles MyBase.Load
SendMessage( _
GetWindow( _
Me.ComboBox1.Handle, _
GW_CHILD _
), _
EM_SETPASSWORDCHAR, _
Asc("*"c), _
0 _
)
Me.ComboBox1.Refresh()
End Sub
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #8
With Deft Fingers, "Fergus Cooney" <fi****@post.com> wrote:
Now I'm with you! :-)


(:

Thx

Regards

Bruce
Nov 20 '05 #9
With Deft Fingers, "Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote:
You may want to grab the handle of the textbox contained in the combobox and
use pinvoke on 'SendMessage' + 'EM_UNDO' and 'EM_REDO' (all code below
untested).


Ouch! So many 'complicated' ways :(

But many Thanks! At least I've got something to take off from

Regards,

Bruce
Nov 20 '05 #10
Hi Mr B,

I thought I'd test it just in case.

Private Sub btnUndo_Click (sender As Object, e As System.EventArgs) _
Handles btnUndo.Click
ComboBox1.Focus
SendKeys.Send ("^Z")
End Sub

Regards,
Fergus

--
=================================================
Thought for the day:
Have you noticed how condescending Herfried can be?

=================================================

(There's a feud going on)
Nov 20 '05 #11
* "Fergus Cooney" <fi****@post.com> scripsit:
=================================================
Thought for the day:
Have you noticed how condescending Herfried can be?

=================================================


Rules of Conduct
<http://www.microsoft.com/communities/conduct/default.mspx>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Mike Maxwell | last post by:
<vent> I see there has been traffic over the years on this gripe, so just let me vent my frustration, and add another reason why 'exit' (or possibly exit() or quit() or halt() or some such) should...
4
by: Scott | last post by:
I am using a TCPIP connection to communicate over port 23 (telnet) to a server, and I am having to mimic normal command line interface you owuld see in a telnet session (i.e. I have to write to...
10
by: chirs | last post by:
I have a code to disable ctrl-v (paste) on the 2nd box. The problem is that when I type ctrl-v, the text shows, then disappear after I release ctrl-v. How can I make it not to show in the box. In...
13
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to...
3
by: Greg | last post by:
I want to be able to capture the user pressing Ctrl+S. I know that the IE browser has a key binding for Ctrl+S but is there any way that I can be notified of this key press anyway. I have found...
3
by: Glen Hong | last post by:
I have set up a hotkey using RegisterHotKey API function for Ctrl-Tab. Firstly, I can rap this when Ctrl-Tab is pressed however if I want to add an addition hotkey how can I distinguish between...
2
by: crjunk | last post by:
I'm trying to write a piece of code that will programatically save a record automatically without me having to add a new ' Row.Item("ADD1") = txtAdd1.Text.Trim.ToUpper ' type command each time I...
2
by: s99999999s2003 | last post by:
hi i have a program that works very similar to tail -f in Unix It will need a Ctrl-C in order to break out of the program. I wish to run this program using python (either thru os.system() or some...
11
by: Bookham Measures | last post by:
Hello As above, my Ctrl + Spacebar for intellisense is not working in VI 6.0. I have checked keyboard assignments and Ctrl + Space is listed for Edit -> CompleteWord. I added Ctrl + Shift +...
21
by: Zytan | last post by:
Instead of Ctrl+Y redoing what's stored in 'future history', it REPLACES that information (which will then be forever lost) with a new command: delete current line. This shortcut is so ridiculous...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.