【发布时间】:2015-02-28 21:33:30
【问题描述】:
当所有复选框都未选中时,我应该如何清除文本框。
private void qualitySetupDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
DataGridView data = this.qualitySetupDataGridView;
int CurrentRow = data.CurrentRow.Index;
foreach (DataGridViewRow Row in data.Rows) {
object cell = Row.Cells[5].EditedFormattedValue;
if (Convert.ToBoolean(cell) == false) {
textBox1.Clear();
}
添加了更多代码。为了更容易理解,我添加了更多代码。
if (Convert.ToBoolean(data.Rows[CurrentRow].Cells[5].EditedFormattedValue) == true)
{
EndsPerInch = double.Parse(data.Rows[CurrentRow].Cells[4].Value.ToString());
Sum = Sum + EndsPerInch;
count++;
Average = Sum / count;
FinalValue = Math.Round(Average, 2);
textBox1.Text = Convert.ToString(FinalValue);
}
else if (Convert.ToBoolean(data.Rows[CurrentRow].Cells[5].EditedFormattedValue) == false)
{
EndsPerInch = double.Parse(data.Rows[CurrentRow].Cells[4].Value.ToString());
Sum = Sum - EndsPerInch;
count--;
Average = Sum / count;
FinalValue = Math.Round(Average, 2);
textBox1.Text = Convert.ToString(FinalValue);
// textBox1.Clear();
count = 0;
Sum = 0;
EndsPerInch = 0;
Average = 0;
FinalValue = 0;
}
这是DataGridView的单元格内容点击中从上到下的代码。
SystemFormatException:
【问题讨论】:
-
我们需要更多关于如何设置数据绑定的信息。请向我们展示代码。
-
添加了代码。现在检查。
标签: c# checkbox datagridview