我正在使用此代码:
// Cell value change event.
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if ((bool)dataGridView1.CurrentCell.Value == true) MessageBox.Show("true");
if ((bool)dataGridView1.CurrentCell.Value == false) MessageBox.Show("false");
MessageBox.Show(dataGridView1.CurrentCell.Value.ToString());
}
Run Code Online (Sandbox Code Playgroud)
它适用于所有列,除了一列带复选框(DataGridViewCheckBoxColumn)
我需要知道复选框列中的值(true或false).
我需要做什么呢?
我需要在值之后添加一个字符.例如:
SELECT brand FROM `autoinfo` WHERE 1
Run Code Online (Sandbox Code Playgroud)
结果:
Audi
Ford
...
Run Code Online (Sandbox Code Playgroud)
我需要那个结果:
Audi w
Ford w
...
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我使用MySQL连接器接收数据表单数据库并将值放到dataset-> dataGridView.然后,当我点击带有复选框的列时,我需要更改日期列中的值:
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.Columns[e.ColumnIndex].Name == "???????")
{
DataGridViewCheckBoxCell checkbox = (DataGridViewCheckBoxCell)dataGridView1.CurrentCell;
bool isChecked = (bool)checkbox.EditedFormattedValue;
DateTime dt = DateTime.Today;
dataGridView1.Rows[e.RowIndex].Cells[4].Value = dt.ToString("yyyy-MM-dd");
}
}
Run Code Online (Sandbox Code Playgroud)
我需要将DateTime转换为MySqlDateTime,以在某些列中插入值.现在我有错误,期望MySqlData类型.
Unable to convert System.DateTime value to MySQL date/time