日期:2014-05-17 浏览次数:20851 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
SqlDataAdapter sqlDA;
DataTable dt;
public Form1()
{
InitializeComponent();
}
private void btnModify_Click(object sender, EventArgs e)
{
dgv.CurrentCell.Value = "123";
DataRowView drv = (DataRowView)dgv.CurrentRow.DataBoundItem;
MessageBox.Show(drv.Row.RowState.ToString());
}
private void Form1_Load(object sender, EventArgs e)
{
string strConn = "Data Source=192.168.1.110;Initial Catalog=GD-Pipe;Persist Security Info=True;User ID=sa;Password=123";
sqlDA = new SqlDataAdapter("SELECT * FROM ModelType", new SqlConnection(strConn));
SqlCommandBuilder sqlCB = new SqlCommandBuilder(sqlDA);
dt = new DataTable();
sqlDA.Fill(dt);
dgv.DataSource = dt;
}
}
}