Beispiel #1
0
        private void Paste1_Click(object sender, EventArgs e)
        {
            // Determine if there is any text in the Clipboard to paste into the text box.
            if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
            {
                // Determine if any text is selected in the text box.
                if (TextBox1.SelectionLength > 0)
                {
                    // Save selection start point and selction length
                    int SelStart  = TextBox1.SelectionStart;
                    int SelLength = TextBox1.SelectionLength;
                    switch (PasteMode)
                    {
                    case PasteModes.BeforeSelection:
                        // Turn off the selection, paste clipboard text then re-show selection
                        // in corrected position after adding the text
                        TextBox1.DeselectAll();
                        TextBox1.Paste();
                        TextBox1.SelectionStart  = SelStart + Clipboard.GetText().Length;
                        TextBox1.SelectionLength = SelLength;
                        break;

                    case PasteModes.AfterSelection:
                        // Turn of the selection to prevent it getting overwritten, paste clipboard
                        // text, then set selection back to how it was
                        TextBox1.DeselectAll();
                        TextBox1.SelectionStart = SelStart + SelLength;
                        TextBox1.Paste();
                        TextBox1.SelectionStart  = SelStart;
                        TextBox1.SelectionLength = SelLength;
                        break;

                    case PasteModes.OverSelection:
                        TextBox1.Paste();
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    TextBox1.Paste();
                }
            }
        }
Beispiel #2
0
        private void Edit(string editMenu)
        {
            switch (editMenu)
            {
            case "Undo":
                if (TextBox1.CanUndo == true)
                {
                    TextBox1.Undo();
                }
                break;

            case "Cut":
                if (TextBox1.SelectedText != "")
                {
                    TextBox1.Cut();
                }
                break;

            case "Copy":
                Clipboard.SetDataObject(TextBox1.SelectedText, true);
                break;

            case "Paste":
                TextBox1.Paste();
                break;

            case "Delete":
                TextBox1.SelectedText = "";
                break;

            case "BingSearch":
                string bingSearch = TextBox1.SelectedText;
                System.Diagnostics.Process.Start(string.Format("https://www.bing.com/search?q={0}", bingSearch));
                break;
            }
        }
Beispiel #3
0
 private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     TextBox1.Paste();
 }
 private void Paste_Click(object sender, RoutedEventArgs e)
 {
     TextBox1.Paste();
 }