Windows窗体-在我的DataGridView中强制“刷新”

菲利普·阿尔梅达(Filipe Almeida)

我是一个新手,正在做我的第一个C#项目(也没有在Haskell和C方面的最少经验),以寻求有关如何在程序中实现小功能的指南。

我有一个DataGridView表(具有3列复选框以及其他内容)供用户填充。连续时,第二个复选框处于选中状态,第一个被选中的复选框必须未选中。我可以执行此操作,但问题是,在我选择表中的其他内容后,第一个选中的对象才被取消选中。

这是与CellValueChanged事件有关的代码(注释中的内容是我试图帮助我的内容)

        if (e.ColumnIndex == 0 || e.ColumnIndex == 1 || tabela_NormasDataGridView.Rows.Count == 0)
        {
            return;
        }
        
        var isChecked = (bool)tabela_NormasDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;

        if (isChecked)
        {
            for (int i = 2; i < 5; i++)
            {
                //Console.WriteLine("og " + e.ColumnIndex);
                DataGridViewCell cell = tabela_NormasDataGridView.Rows[e.RowIndex].Cells[i];
                //Console.WriteLine("segunda " + cell.ColumnIndex);
                if (cell.ColumnIndex != e.ColumnIndex)
                {
                    cell.Value = false;
                    //this.Refresh();
                }
            }
        }

感谢您的时间!

拉尔斯科技

尝试提交更改以强制刷新:

void tabela_NormasDataGridView_CurrentCellDirtyStateChanged(object sender, EventArgs e) {
    tabela_NormasDataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
}

确保将事件连接起来。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Windows窗体刷新datagridview

来自分类Dev

Windows窗体DataGridView中的图像

来自分类Dev

验证DataGridView Windows窗体

来自分类Dev

在Windows窗体中打印

来自分类Dev

Windows 窗体 DataGridView 快速加载

来自分类Dev

datagridview在Windows窗体中显示空行

来自分类Dev

datagridview在Windows窗体中显示空行

来自分类Dev

Windows窗体中的布局困难

来自分类Dev

MMC在Windows窗体中对齐

来自分类Dev

Windows窗体中的数据绑定

来自分类Dev

在C ++ Windows窗体应用程序中打开新窗体

来自分类Dev

如何在C#Windows窗体中创建选项窗体?

来自分类Dev

谁在Windows窗体程序中调用窗体加载事件?

来自分类Dev

Windows窗体中窗体最小化的奇怪效果

来自分类Dev

在 Windows 窗体中关闭模态窗体的计时器

来自分类Dev

在 Windows 窗体设计器中锁定窗体大小

来自分类Dev

在Windows窗体中调整Windows /控件比例

来自分类Dev

Windows窗体强制转换Button类

来自分类Dev

PowerShell-DataGridView Windows窗体拖放问题

来自分类Dev

Windows窗体中使用C#的DataGridView

来自分类Dev

创建Telerik层次结构DataGridView Windows窗体

来自分类Dev

我会在Windows窗体中显示list <>,我该怎么做?与dataGridView吗?

来自分类Dev

Windows窗体DataGridView中的手风琴

来自分类Dev

Windows窗体DataGridView中的手风琴

来自分类Dev

将Windows窗体中的DataGridView绑定到列表<List <T >>

来自分类Dev

如何清除C#Windows窗体中的DataGridView?

来自分类Dev

如何使用windows窗体在datagridview中显示计数

来自分类Dev

为什么我的Windows窗体冻结并死锁?

来自分类Dev

Mono Windows窗体中的从右到左文本