要求是,在EXCEL中选中一列值,比如:123
123
34
5
45
然后按CTRL+C,或者复制,要求在C#中,取出这些值,然后分行取值,放到一列文本框中请问有什么控件能用WINDOWS的剪贴板。或者有什么思路解决这个问题!谢谢

解决方案 »

  1.   

    it is easy.
    you can use: System.Windows.Forms.Clipboard
    class
      

  2.   

    http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vbcon/html/vbtskretrievinginformationfromclipboard.asp
      

  3.   

    现在的问题是我是WEB项目,但是用到了WINDOWS后,就报错了
      

  4.   

    System.Windows.Forms.IDataObject iData = System.Windows.Forms.Clipboard.GetDataObject();
    if(iData.GetDataPresent(System.Windows.Forms.DataFormats.Text)) 
    {
    string strValue=(string)iData.GetData(System.Windows.Forms.DataFormats.Text);
    string[] res=strValue.Split((char)13);
    foreach (string str in res)
    {
    MessageBox.Show(str.Trim());
    }
    }
      

  5.   

    根据MSDN上的代码,为很么执行的时候会在"if(iData.GetDataPresent(DataFormats.Text)) "报System.NullReferenceException错
    private void Page_Load(object sender, System.EventArgs e)
    {
    System.Windows.Forms.IDataObject iData = System.Windows.Forms.Clipboard.GetDataObject();
    if(iData.GetDataPresent(DataFormats.Text)) 
    {
    string strValue=iData.GetData(DataFormats.Text).ToString();

    Label1.Text="strValue";
    } }