C# DevExpress XtraGrid GridControl 帮助 - 使单元格中的复选框不可见

发布于 2024-08-24 10:10:45 字数 268 浏览 6 评论 0原文

我有一个 GridControl 视图,其中填充了一列作为布尔值,以将值显示为复选框。

但是,我希望根据其他列的状态隐藏一些复选框。我尝试使用 gridView_CustomDrawCell() 事件,但找不到合适的属性。

我希望找到一个 visible 属性设置为 false,但似乎没有。

也许可以在填充视图时隐藏复选框,但我想不出一个。

有谁知道这是否可能,以及如何实现?

非常感谢!

I have a GridControl view which is being populated with one column as a Boolean to show the value as a checkbox.

However, I wish to hide some checkboxes based on the state of other columns. I have tried to use the gridView_CustomDrawCell() event but cannot find a suitable property.

I expected to find a visible property to set to false but there doesn't seem to be one.

Maybe it is possible to hide the checkbox when the view is being populated but I cannot think of one.

Does anyone know if this is possible, and how?

Many thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夕色琉璃 2024-08-31 10:10:45

您可以尝试清除 Graphics 并将事件标记为已处理:

private void gridView_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
{
    if (ConditionIsMet())
    {
        e.Graphics.Clear(e.Appearance.BackColor);
        e.Handled = true;
    }
}

如果它不起作用,这里有另一个想法:处理 CustomRowCellEditCustomRowCellEditForEditing 事件,并删除编辑器:

private void gridView_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
{
    if (ConditionIsMet())
    {
        e.RepositoryItem = null;
    }
}

You could try to clear the Graphics and mark the event as handled :

private void gridView_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
{
    if (ConditionIsMet())
    {
        e.Graphics.Clear(e.Appearance.BackColor);
        e.Handled = true;
    }
}

If it doesn't work, here's another idea : handle the CustomRowCellEdit and CustomRowCellEditForEditing events, and remove the editor :

private void gridView_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
{
    if (ConditionIsMet())
    {
        e.RepositoryItem = null;
    }
}
握住我的手 2024-08-31 10:10:45

我在一个项目中所做的是将 RadioGroup 设置为没有项目的控件,因此它显示为空白。

private void viewTodoList_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
        {
            if (e.Column == CheckMarkColumn)
            {
                if (ConditionIsMet())
                {
                    e.RepositoryItem = new DevExpress.XtraEditors.Repository.RepositoryItemRadioGroup();
                }
            }
        }

What I did for this on a project was to set a RadioGroup as the control with no items so it appeared as blank.

private void viewTodoList_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
        {
            if (e.Column == CheckMarkColumn)
            {
                if (ConditionIsMet())
                {
                    e.RepositoryItem = new DevExpress.XtraEditors.Repository.RepositoryItemRadioGroup();
                }
            }
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文