文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>excel 内容粘贴到datagridview

excel 内容粘贴到datagridview

时间:2010-10-12  来源:abenz

        private void Form1_Load(object sender, EventArgs e)
        {
            dataGridView1.Columns.Add("FIELD_NAME", "字段名");
            dataGridView1.Columns.Add("FIELD_DESC", "字段描述");
            dataGridView1.Columns.Add("FIELD_TYPE", "字段类型");
            dataGridView1.Columns.Add("FIELD_LEN", "长度");
        }

        private void ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string pasteText = Clipboard.GetText();
                if (string.IsNullOrEmpty(pasteText))
                {
                    return;
                }

                string[] lines = pasteText.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);               
                foreach (string line in lines)
                {                   
                    string[] vals = line.Split(new char[] { '\t' });                                       
                    dataGridView1.Rows.Add(vals);
                }
            }
            catch
            {
                //
            }           
        }

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载