Question

I create a notepad (MDI application) on the Windows form application (C#), and I need to make a general text clipboard on all copies of the document. For that I use a variable BufferText of type string in main form.

  public string BufferText = "";

In the form of the document(name blank) creating the object of main form(name Form1)

public Form1 a = new Form1(); and work with it.

public void Cut()
{
    a.BufferText = richTextBox1.SelectedText;
    richTextBox1.SelectedText = "";
}
public void Copy()
{
    a.BufferText = richTextBox1.SelectedText;
}
public void Paste()
{
    richTextBox1.SelectedText = a.BufferText;
}

But it allows me to only work with clipboard only one object of the form blank. How do the possibility of exchanging between several objects form blank?

Was it helpful?

Solution

Try using the built in Clipboard support instead:

richTextBox1.Copy();
richTextBox1.Cut();
richTextBox1.Paste();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top