.Net常用技巧_将DataGridView的内容转换成DataTable
2020-12-13 03:37
标签:datagridview style blog color os io .Net常用技巧_将DataGridView的内容转换成DataTable,搜素材,soscw.com .Net常用技巧_将DataGridView的内容转换成DataTable 标签:datagridview style blog color os io 原文地址:http://www.cnblogs.com/yuyuanfeng/p/3811501.htmlusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using Utility;
namespace MyTool
{
public class GetDgvToTable
{
public static DataTable GetTable(DataGridView dgv)
{
DataTable dt = new DataTable();
for (int count = 0; count )
{
DataColumn dc = new DataColumn(dgv.Columns[count].Name.ToString()); dt.Columns.Add(dc);
}
for (int count = 0; count )
{
DataRow dr = dt.NewRow();
for (int countsub = 0; countsub )
{
dr[countsub] = Convert.ToString(dgv.Rows[count].Cells[countsub].Value);
}
dt.Rows.Add(dr);
} return dt;
}
}
}
上一篇:C API函数描述(O-R)
下一篇:网站架构模式
文章标题:.Net常用技巧_将DataGridView的内容转换成DataTable
文章链接:http://soscw.com/essay/27954.html