100分求winfrom下的DataGrid的一个问题 DataGrid的内容改变了是触发哪一个事件。比如用户在DataGrid中增加或者修改了一个记录中的属性应该是触发哪一个事件。100分吐血狂求啊~~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Private Sub dg_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dg.CurrentCellChanged End Sub 帮你差了,C#里面的CurrentCellChanged事件在事件的"属性"那一拦里 楼上兄弟,应该不是这个吧,这个是datagrid的cell焦点改变就触发,而不是cell中的text改变而触发。 呵呵,不好意思哈!仔细看了下,好象没有这个属性哦.我一直用的第三方控件C1flexgrid.1.使用第3芳控件2.你也可以自己写个事件3.可以利用数据源的行状态来判断 我现在是想做这样一个功能,一个窗体中有一个dataGrid控件,一个保存按钮。一开始保存按钮是enable的,只有在dataGrid中的任何一个cell的text有变更的时候才触发保存按钮为可用状态。而CurrentCellChanged事件是在鼠标焦点一进入就触发了。 to:meiqingsong(阿飛)CellBeginEdit()CellEndEdit()这两个是方法还是事件,如果是事件的话在哪里找呢? Look samplehttp://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q773q to:yz1199(逃离孤独)自己写个事件要怎么写呢,我没自己写过事件,能发个源码来吗。 哇~这为Knight94(愚翁)大大发的是英文的资料,我看看~ public class DataGridColorTextBoxColumn : DataGridTextBoxColumn { public DataGridColorTextBoxColumn ():base() { }this.TextBox.TextChanged += new EventHandler(TextBox_TextChanged);}过两天我将实现DATAGRID单元格变色的代码发布到我的blog上 public event System.EventHandler TextChanged System.Windows.Forms.DataGrid 的成员 CellBeginEdit()CellEndEdit()是事件,我用的是VS2005不知道VS2003有没有, to:lgyangell() public event System.EventHandler TextChangeddataGrid找不到该事件,兄弟用的是2005吗。to:meiqingsong(阿飛) CellBeginEdit()CellEndEdit()这两个在2003下没找到。 to:serversql(啊初) 你这个可以,但是我不知道要怎么实现~~ 2003下面就有,你直接继承dataGrid这个类。TextChanged是这个类的一个成员。继承过来以后就可以用了~你看一下类视图就明白了 How can I tell if the current row has changed and whether I am on the AddNew row or not? private System.Windows.Forms.DataGrid dataGrid1; private BindingManagerBase bindingManager; private void Form1_Load(object sender, System.EventArgs e) { // Creating connection and command sting string conStr = @"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb"; string sqlStr = "SELECT * FROM Employees"; // Create connection object OleDbConnection conn = new OleDbConnection(conStr); // Create data adapter object OleDbDataAdapter da = new OleDbDataAdapter(sqlStr,conn); // Create a dataset object and fill with data using data adapter's Fill method DataSet ds = new DataSet(); da.Fill(ds, "Employees"); dataGrid1.DataSource = ds.Tables["Employees"]; bindingManager = this.BindingContext[dataGrid1.DataSource]; bindingManager.PositionChanged += new System.EventHandler(RowChanged); } private void RowChanged(object sender, System.EventArgs e) { Console.WriteLine("RowChanged " + bindingManager.Position.ToString() ); bool lastRow = bindingManager.Count > ((DataTable)dataGrid1.DataSource).Rows.Count; if(lastRow) Console.WriteLine("lastRow"); } 这个就是利用了数据源的方式来添加一个事件的.这是增加行的例子 to:lgyangell()你说的方法不错,但是实在搞不来。你确定你有用过吗?好象serversql(啊初)的方法才是正确的。 我用StreamReader读取一个文本文件,怎么判断第二行的首个字母? c# 方法引用问题!! [C#]获取文件夹的名称 有谁知道Code128条形码的校验码是怎样计算的吗? disable gesture for IE 线程参数问题 是c#的高手就应该进来看一下 怎么把一个长度为n的数组放到10个数组里面,10个数组的大小根据大的数组动态生成 请问一个异常处理的问题,catch中如果抛出异常的问题 写共享软件用什么编程语言好 ̄请发表点看法? 有关DataGrid分别绑定来自两个表中的数据? 如果解决超大文件上传 >500m
1.使用第3芳控件2.你也可以自己写个事件3.可以利用数据源的行状态来判断
一开始保存按钮是enable的,只有在dataGrid中的任何一个cell的text有变更的时候才触发保存按钮为可用状态。而CurrentCellChanged事件是在鼠标焦点一进入就触发了。
CellBeginEdit()
CellEndEdit()
这两个是方法还是事件,如果是事件的话在哪里找呢?
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q773q
自己写个事件要怎么写呢,我没自己写过事件,能发个源码来吗。
{
public DataGridColorTextBoxColumn ():base()
{ }
this.TextBox.TextChanged += new EventHandler(TextBox_TextChanged);
}
过两天我将实现DATAGRID单元格变色的代码发布到我的blog上
System.Windows.Forms.DataGrid 的成员
CellEndEdit()
是事件,我用的是VS2005不知道VS2003有没有,
public event System.EventHandler TextChanged
dataGrid找不到该事件,兄弟用的是2005吗。to:meiqingsong(阿飛)
CellBeginEdit()
CellEndEdit()
这两个在2003下没找到。
你这个可以,但是我不知道要怎么实现~~
private BindingManagerBase bindingManager;
private void Form1_Load(object sender, System.EventArgs e)
{
// Creating connection and command sting
string conStr = @"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb";
string sqlStr = "SELECT * FROM Employees";
// Create connection object
OleDbConnection conn = new OleDbConnection(conStr);
// Create data adapter object
OleDbDataAdapter da = new OleDbDataAdapter(sqlStr,conn);
// Create a dataset object and fill with data using data adapter's Fill method
DataSet ds = new DataSet();
da.Fill(ds, "Employees");
dataGrid1.DataSource = ds.Tables["Employees"];
bindingManager = this.BindingContext[dataGrid1.DataSource];
bindingManager.PositionChanged += new System.EventHandler(RowChanged);
}
private void RowChanged(object sender, System.EventArgs e)
{
Console.WriteLine("RowChanged " + bindingManager.Position.ToString() );
bool lastRow = bindingManager.Count > ((DataTable)dataGrid1.DataSource).Rows.Count;
if(lastRow)
Console.WriteLine("lastRow");
}
这个就是利用了数据源的方式来添加一个事件的.这是增加行的例子
你说的方法不错,但是实在搞不来。你确定你有用过吗?好象serversql(啊初)的方法才是正确的。