2 回答
TA贡献1911条经验 获得超7个赞
378 次查看 0 个解决方案,但我自己找到了一个 chkbox 对象有两个事件处理程序,一个用于检查,一个用于 deceked。
private void Chk_All_Checked(object sender, RoutedEventArgs e)
{
sqliteCon.Open();
if (sqliteCon.State == System.Data.ConnectionState.Open)
{
if (chk_All.IsChecked == true) {
string q = @"UPDATE tabList
SET selection = 1";
SqlCommand cmd = new SqlCommand(q, sqliteCon);
cmd.ExecuteNonQuery();
MessageBox.Show("All Items Checked");
}
}
sqliteCon.Close();
}
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{
sqliteCon.Open();
if (sqliteCon.State == System.Data.ConnectionState.Open)
{
if (chk_All.IsChecked == false)
{
string q2 = @"UPDATE tabList
SET selection = 0";
SqlCommand cmd2 = new SqlCommand(q2, sqliteCon);
cmd2.ExecuteNonQuery();
MessageBox.Show("All Items DeChecked");
}
}
sqliteCon.Close();
}
TA贡献1801条经验 获得超15个赞
使用以下代码:
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0 && e.ColumnIndex == 0)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Index == e.RowIndex)
{
row.Cells["checkBoxColumn"].Value =
!Convert.ToBoolean(row.Cells["checkBoxColumn"].EditedFormattedValue);
}
else
{
row.Cells["checkBoxColumn"].Value = false;
}
}
}
}
- 2 回答
- 0 关注
- 143 浏览
添加回答
举报