可"TrueValueChanged()"和"FalseValueChanged"和"AllowNullChanged"事件无法响应,没有反应的
为什么?
如何处理该事件(我已查过MSDN,仍无反应)?
是不是有其他的方法来响应??
13 个解决方案
#1
DataGrid_ItemCommand
#2
可以贴出代码吗?
#3
// 关键代码如下:但没有反应~!
public void AddTableStyleColumn()
{
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "Customers";
DataGridBoolColumn boolCol = new DataGridBoolColumn();
boolCol.MappingName = "chkChoose";
boolCol.HeaderText = "是/否";
boolCol.Width = 70;
boolCol.AllowNull = false;
boolCol.TrueValueChanged +=new EventHandler(boolCol_TrueValueChanged);
ts1.GridColumnStyles.Add(boolCol);
dataGrid1.TableStyles.Add(ts1);
}
private void boolCol_TrueValueChanged(object sender, EventArgs e)
{
MessageBox.show("HELLO");
}
public void AddTableStyleColumn()
{
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "Customers";
DataGridBoolColumn boolCol = new DataGridBoolColumn();
boolCol.MappingName = "chkChoose";
boolCol.HeaderText = "是/否";
boolCol.Width = 70;
boolCol.AllowNull = false;
boolCol.TrueValueChanged +=new EventHandler(boolCol_TrueValueChanged);
ts1.GridColumnStyles.Add(boolCol);
dataGrid1.TableStyles.Add(ts1);
}
private void boolCol_TrueValueChanged(object sender, EventArgs e)
{
MessageBox.show("HELLO");
}
#4
代码已经贴出来,求助~!
#5
private void boolCol_TrueValueChanged(object sender, EventArgs e)
{
AddTableStyleColumn();
MessageBox.show("HELLO");
}
{
AddTableStyleColumn();
MessageBox.show("HELLO");
}
#6
xuexi
#7
up~~~
这个没遇到过~~
学习一下~~~
这个没遇到过~~
学习一下~~~
#8
TO: yaopeng117(尋找屬於自己的壹切)
根据你的方法,我试过,任是没有响应这个事件(你的代码);
求问高手们
根据你的方法,我试过,任是没有响应这个事件(你的代码);
求问高手们
#9
帮你顶,我也遇到这问题啦,点了鼠标没有反应。
#10
楼主没有理解这几个事件是怎么触发的。这几个事件是对应的属性修改后才触发,而不是对应列的值改变。要捕捉列值的改变,可以用DataTable对像的ColumnChanged或ColumnChanging事件
#11
我后来是这样做的:
用的MouseDown。然后再写的,将就可以用啦
用的MouseDown。然后再写的,将就可以用啦
#12
源码下载:在DataGridColumnStyle的单元格中使用DateTimePicker、ComboBox、NumericUpDown等控件
http://community.csdn.net/Expert/topic/3522/3522038.xml?temp=.2270777
#13
/// <summary>
/// 对DataGrid中的CheckBox进行值判断,并对数据库做出修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataSource_CurrentCellChanged(object sender, System.EventArgs e)
{
try
{
string temp = dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),0].ToString();
this.dataGridView.Select(dataGridView.CurrentCell.RowNumber);
DataAccess data = new DataAccess();
//判断是否点中的是CheckBox列,以保证其值正确更改
if(dataGridView.CurrentCell.ColumnNumber == 12)
{
//判断CheckBox单元格的值,并根据其值更新数据库
if(dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12].ToString() == "False")
{
dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12] = true;
string query_sql = "update accounttype set accflag = '1' where id = '" + temp + "'";
data.ExecuteSQL(query_sql);
}
else if(dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12].ToString() == "True")
{
dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12] = false;
string query_sql = "update accounttype set accflag = '0' where id = '" + temp + "'";
data.ExecuteSQL(query_sql);
}
}
else
{
//选中的不是CheckBox列就跳出此过程
return;
}
}
catch
{
MessageBox.Show("表格中未有任何记录!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
/// 对DataGrid中的CheckBox进行值判断,并对数据库做出修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataSource_CurrentCellChanged(object sender, System.EventArgs e)
{
try
{
string temp = dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),0].ToString();
this.dataGridView.Select(dataGridView.CurrentCell.RowNumber);
DataAccess data = new DataAccess();
//判断是否点中的是CheckBox列,以保证其值正确更改
if(dataGridView.CurrentCell.ColumnNumber == 12)
{
//判断CheckBox单元格的值,并根据其值更新数据库
if(dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12].ToString() == "False")
{
dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12] = true;
string query_sql = "update accounttype set accflag = '1' where id = '" + temp + "'";
data.ExecuteSQL(query_sql);
}
else if(dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12].ToString() == "True")
{
dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12] = false;
string query_sql = "update accounttype set accflag = '0' where id = '" + temp + "'";
data.ExecuteSQL(query_sql);
}
}
else
{
//选中的不是CheckBox列就跳出此过程
return;
}
}
catch
{
MessageBox.Show("表格中未有任何记录!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
#1
DataGrid_ItemCommand
#2
可以贴出代码吗?
#3
// 关键代码如下:但没有反应~!
public void AddTableStyleColumn()
{
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "Customers";
DataGridBoolColumn boolCol = new DataGridBoolColumn();
boolCol.MappingName = "chkChoose";
boolCol.HeaderText = "是/否";
boolCol.Width = 70;
boolCol.AllowNull = false;
boolCol.TrueValueChanged +=new EventHandler(boolCol_TrueValueChanged);
ts1.GridColumnStyles.Add(boolCol);
dataGrid1.TableStyles.Add(ts1);
}
private void boolCol_TrueValueChanged(object sender, EventArgs e)
{
MessageBox.show("HELLO");
}
public void AddTableStyleColumn()
{
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "Customers";
DataGridBoolColumn boolCol = new DataGridBoolColumn();
boolCol.MappingName = "chkChoose";
boolCol.HeaderText = "是/否";
boolCol.Width = 70;
boolCol.AllowNull = false;
boolCol.TrueValueChanged +=new EventHandler(boolCol_TrueValueChanged);
ts1.GridColumnStyles.Add(boolCol);
dataGrid1.TableStyles.Add(ts1);
}
private void boolCol_TrueValueChanged(object sender, EventArgs e)
{
MessageBox.show("HELLO");
}
#4
代码已经贴出来,求助~!
#5
private void boolCol_TrueValueChanged(object sender, EventArgs e)
{
AddTableStyleColumn();
MessageBox.show("HELLO");
}
{
AddTableStyleColumn();
MessageBox.show("HELLO");
}
#6
xuexi
#7
up~~~
这个没遇到过~~
学习一下~~~
这个没遇到过~~
学习一下~~~
#8
TO: yaopeng117(尋找屬於自己的壹切)
根据你的方法,我试过,任是没有响应这个事件(你的代码);
求问高手们
根据你的方法,我试过,任是没有响应这个事件(你的代码);
求问高手们
#9
帮你顶,我也遇到这问题啦,点了鼠标没有反应。
#10
楼主没有理解这几个事件是怎么触发的。这几个事件是对应的属性修改后才触发,而不是对应列的值改变。要捕捉列值的改变,可以用DataTable对像的ColumnChanged或ColumnChanging事件
#11
我后来是这样做的:
用的MouseDown。然后再写的,将就可以用啦
用的MouseDown。然后再写的,将就可以用啦
#12
源码下载:在DataGridColumnStyle的单元格中使用DateTimePicker、ComboBox、NumericUpDown等控件
http://community.csdn.net/Expert/topic/3522/3522038.xml?temp=.2270777
#13
/// <summary>
/// 对DataGrid中的CheckBox进行值判断,并对数据库做出修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataSource_CurrentCellChanged(object sender, System.EventArgs e)
{
try
{
string temp = dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),0].ToString();
this.dataGridView.Select(dataGridView.CurrentCell.RowNumber);
DataAccess data = new DataAccess();
//判断是否点中的是CheckBox列,以保证其值正确更改
if(dataGridView.CurrentCell.ColumnNumber == 12)
{
//判断CheckBox单元格的值,并根据其值更新数据库
if(dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12].ToString() == "False")
{
dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12] = true;
string query_sql = "update accounttype set accflag = '1' where id = '" + temp + "'";
data.ExecuteSQL(query_sql);
}
else if(dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12].ToString() == "True")
{
dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12] = false;
string query_sql = "update accounttype set accflag = '0' where id = '" + temp + "'";
data.ExecuteSQL(query_sql);
}
}
else
{
//选中的不是CheckBox列就跳出此过程
return;
}
}
catch
{
MessageBox.Show("表格中未有任何记录!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
/// 对DataGrid中的CheckBox进行值判断,并对数据库做出修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataSource_CurrentCellChanged(object sender, System.EventArgs e)
{
try
{
string temp = dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),0].ToString();
this.dataGridView.Select(dataGridView.CurrentCell.RowNumber);
DataAccess data = new DataAccess();
//判断是否点中的是CheckBox列,以保证其值正确更改
if(dataGridView.CurrentCell.ColumnNumber == 12)
{
//判断CheckBox单元格的值,并根据其值更新数据库
if(dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12].ToString() == "False")
{
dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12] = true;
string query_sql = "update accounttype set accflag = '1' where id = '" + temp + "'";
data.ExecuteSQL(query_sql);
}
else if(dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12].ToString() == "True")
{
dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),12] = false;
string query_sql = "update accounttype set accflag = '0' where id = '" + temp + "'";
data.ExecuteSQL(query_sql);
}
}
else
{
//选中的不是CheckBox列就跳出此过程
return;
}
}
catch
{
MessageBox.Show("表格中未有任何记录!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}