Control + C & V and Icon Problems

BrandonMPSMI

Active member
Joined
Oct 8, 2008
Messages
43
Programming Experience
Beginner
Okay my calculator is done except for two things...

I need to be able to copy to the clipboard when I press Control C

(Same thing for paste except copy to the txtdisplay)

Now there's something I don't understand about the icon. When i changed it to a different picture the small icon didn't change but the large one did. What's wrong.

Thanx guys
 
In the form's Keydown event you can check for a control C or control V with this code:
VB.NET:
If e.Modifiers = Keys.Control Then
    e.Handled = e.KeyCode = Keys.C OrElse e.KeyCode = Keys.V
End If
As for your icon problem, you'll need to explain more.
 
It tells me that "e.keycode" and "e.modifiers" is not a member of System.Windows.Forms.KeyPressEventArgs

What's wrong with my code =(

I fixed the icon so don't worry about it. Thankyou anyways.
 
BrandonMPSMI said:
KeyPressEventArgs
JB said "Keydown event", not KeyPress event... I'd say KeyUp event, because it doesn't repeat if you should happen to be slow when keyboarding.
 
When you detect the Ctrl-C key combination you can put your data to clipboard using the Clipboard class. It has several Set... methods that you can use to set various types of data, for example SetText to set string data. These methods are shared, which means you don't create an instance of the Clipboard class to call them, instead you just qualify the method call with the class name like this:
VB.NET:
Clipboard.SetText("hello clipboard")
Similarly the Clipboard class has several Get... method to get data from the clipboard.
 
I'm unclear as to where physically you put the code.

Give me an example like this...

VB.NET:
If control C is pressed Then
  'Code for copying (I know what to do here)
End IF
IF Control V is pressed Then
  'Code for pasting (I know what to do here also)
End If
 
VB.NET:
If e.Control Then
    If e.KeyCode = Keys.C Then

    End If
End If
 
Back
Top