|
-
May 11th, 2005, 03:56 PM
#1
Thread Starter
Lively Member
How do you program a main menu bar?
What is the code to make the cut, copy, and paste buttons work? If someone could respond soon that would be helpful, thanks.
-
May 11th, 2005, 05:10 PM
#2
Re: How do you program a main menu bar?
I did the copy and paste, I'm sure the cut is very similar.
VB Code:
Private Sub mnuCopy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuCopy.Click
For Each oControl As Control In Me.Controls
If oControl.Focused Then
If TypeOf oControl Is TextBox Then
If CType(oControl, TextBox).SelectionLength > 0 Then
CType(oControl, TextBox).Copy()
End If
End If
End If
Next
End Sub
Private Sub mnuPaste_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuPaste.Click
For Each oControl As Control In Me.Controls
If oControl.Focused Then
If TypeOf oControl Is TextBox Then
If Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) = True Then
CType(oControl, TextBox).Paste()
End If
End If
End If
Next
End Sub
Last edited by wild_bill; May 12th, 2005 at 09:22 AM.
-
May 12th, 2005, 03:03 PM
#3
Thread Starter
Lively Member
Re: How do you program a main menu bar?
ummmmmmm..... it didnt work
-
May 12th, 2005, 03:05 PM
#4
Re: How do you program a main menu bar?
Okay, I'll use my super psychic powers to determine the exception, and I'll get back to you. Just kidding. Did you copy/paste the entire thing, or did you create your own menu click events?
-
May 12th, 2005, 03:09 PM
#5
Thread Starter
Lively Member
Re: How do you program a main menu bar?
wait no it does work but I still cant get the cut to work.
-
May 12th, 2005, 03:17 PM
#6
Re: How do you program a main menu bar?
I made a new menu item, mnuCut. I went into my Form code and selected mnuCut, then selected the Click event, this created a new sub. I copied the code from the copy sub, pasted it into the new sub, and replaced the .Copy() with a .Cut(), and it worked.
-
Jun 3rd, 2005, 07:01 PM
#7
Thread Starter
Lively Member
Re: How do you program a main menu bar?
Do you know how to get a save, load and print buttons to work??
If there is somebody here more of a noob you can have my spot as noob.
-
Jun 4th, 2005, 01:21 AM
#8
Re: How do you program a main menu bar?
The simplest way to code Cut, Copy and Paste is to use SendKeys.Send() to send the Ctrl+X, Ctrl+C and Ctrl+V key combinations to your app
VB Code:
SendKeys.Send(^X) 'Cut.
SendKeys.Send(^C) 'Copy.
SendKeys.Send(^V) 'Paste.
That way you don't have to fiddle around to work out whether the correct type of control is focused and what text is selected. As far as Save, Load and Print are concerned, they mean different things to different apps, so it is up to you. You may want to use the SaveFileDialog, OpenFileDialog and PrintDialog classes in some way. To print, you will generally be using the PrintDocument class and its PrintPage event. You may also want to employ a PrintPreviewDialog.
-
Dec 8th, 2005, 12:20 PM
#9
Frenzied Member
Re: How do you program a main menu bar?
Just a side note,... this code works better if you put quotes around the value.
VB Code:
Call SendKeys.Send("^C") 'Copy.
~Peter

-
Dec 8th, 2005, 01:10 PM
#10
Re: How do you program a main menu bar?
i just use the Clipboard object directly
Clipboard.SetDataObject()
Clipboard.GetDataObject()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|