Csharp/C Sharp by API/System.Windows.Forms/Clipboard

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Clipboard.GetDataObject()

 
using System;
using System.Drawing;
using System.Collections;
using System.ruponentModel;
using System.Data;
using System.Windows.Forms;
public class MainClass {

    public static void Main(string[] args) {
        IDataObject iData = Clipboard.GetDataObject();
        if (iData.GetDataPresent(DataFormats.Text)) {
            Console.WriteLine((String)iData.GetData(DataFormats.Text));
        }
        if (iData.GetDataPresent(DataFormats.Bitmap)) {
            Image img = (Bitmap)iData.GetData(DataFormats.Bitmap);
        }
    }
}


Clipboard.SetDataObject

 

  using System;
  using System.Drawing;
  using System.Collections;
  using System.ruponentModel;
  using System.Data;
  using System.Windows.Forms;
  
  public class MainClass
  {
    public static void Main(string[] args)
    {
        Clipboard.SetDataObject("data");
    }
  }