DataGrid有三中绑定数据的方法,二楼介绍了一种,我就再介绍一种吧,dataGridView1.SetDataBinding(DataSet."表名");插入删除的话,放一个例题上去吧
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace DataGridTest
{
public class frmForm:System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dbgNewGrid;
private DataTable tbSourceTable;
private System.Windows.Forms.Button cmdFocus;
private System.ComponentModel.Container components = null;
public frmForm()
{
InitializeComponent();
PopulateGrid();
}
protected override void Dispose( bool disposing )
{
if ( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
private void InitializeComponent()
{
this.dbgNewGrid = new System.Windows.Forms.DataGrid();
this.cmdFocus = new System.Windows.Forms.Button();