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?

Était-ce utile?

La solution

Try using the built in Clipboard support instead:

richTextBox1.Copy();
richTextBox1.Cut();
richTextBox1.Paste();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top