两个TEXTBOX,一个DATAGRIDVIEW。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication59
{
public partial class Form1 : Form
{
DataTable dt;
int rowIndex = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
dt = new DataTable();
dt.Columns.Add(" ");
dt.Columns.Add("A");
dt.Columns.Add("B");
this.dataGridView1.DataSource = dt;
}
private void button1_Click(object sender, EventArgs e)
{
rowIndex++;
DataRow dr = dt.NewRow();
dr[0] = rowIndex;
dr[1] = this.textBox1.Text;
dr[2] = this.textBo