c# 一个问题,DATAGRIDVIEW重些时碰到的错误,请高手指点
using System;using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
using System.Drawing;
namespace CHANCE
{
public partial class CsDataGridView : DataGridView
{
public CsDataGridView()
{
InitializeComponent();
}
public CsDataGridView(IContainer container)
{
container.Add(this);
InitializeComponent();
}
#region FillAll
public void FillAll()
{
System.Data.SqlClient.SqlConnection cn;
cn = new SqlConnection("Data Source=192.168.10.20;Initial Catalog=Northwind;User ID=sa");
cn.Open();
string sql;
sql = "Select * from Products";
System.Data.SqlClient.SqlDataAdapter da = new SqlDataAdapter(sql, cn);
//DataTable dt = new DataTable(); ;
DataSet dt = new DataSet();
da.Fill(dt);
//this.VirtualMode = true;
this.DataSource = dt.Tables[0];
cn.Close();
}
#endregion
}
}
这是重写--
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TestGDGV_CSharp
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
this.csDataGridView1.FillAll();
}
private void csDataGridView1_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
{
MessageBox.Show("ppp");
}
}
}
再引用控件后,使用FILLALL填充数据,怎么触发了RowsRemoved?请指示. --------------------编程问答-------------------- 我想用this.csDataGridView1.Update()可以吗?
高手继续回答!! --------------------编程问答-------------------- this.csDataGridView1.FillAll();
-----这是重写里的一个方法,目的是填充数据,this.csDataGridView1.Update() 这可能达不到目的吧 --------------------编程问答-------------------- 不行吧 --------------------编程问答--------------------
=这答案! --------------------编程问答-------------------- MS不可以吧
补充:.NET技术 , C#