zoukankan      html  css  js  c++  java
  • 20161013001 DataGridView 数据转 DataTable

        DataTable dt2 =  GetDgvToTable(Form_CY_ProjectRequirements_D);
        MessageBox.Show( dt2.Rows.Count.ToString());

        ////

        protected  DataTable GetDgvToTable(DataGridView dgv)
            {
                DataTable dt = new DataTable();
                for (int count = 0; count < dgv.Columns.Count; count++)
                {
                    DataColumn dc = new DataColumn(dgv.Columns[count].Name.ToString());
                    dt.Columns.Add(dc);
                }
                for (int count = 0; count < dgv.Rows.Count; count++)
                {
                    DataRow dr = dt.NewRow();
                    for (int countsub = 0; countsub < dgv.Columns.Count; countsub++)
                    {
                        dr[countsub] = Convert.ToString(dgv.Rows[count].Cells[countsub].Value);
                    }
                    dt.Rows.Add(dr);
                }
                return dt;
            }

  • 相关阅读:
    团队冲刺第五天
    单词统计包括其续
    团队冲刺第四天
    团队冲刺第三天
    团队冲刺第二天
    团队冲刺第一天
    软件工程第九周总结
    软件工程第八周总结
    《大道至简》阅读笔记二
    《大道至简》阅读笔记一
  • 原文地址:https://www.cnblogs.com/hutie1980/p/5956619.html
Copyright © 2011-2022 走看看