首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Janus 4 GridEx禁用行

Janus 4 GridEx禁用行
EN

Stack Overflow用户
提问于 2012-10-27 19:58:14
回答 2查看 2.8K关注 0票数 0

我有一个Janus4的GridEx控件,其中包含一个复选框列。我需要能够禁用某些行(即使它们不可选/灰显),这取决于特定列的值。网格的数据是从数据库加载的。

任何帮助都将不胜感激。

EN

回答 2

Stack Overflow用户

发布于 2013-08-05 10:32:47

您必须利用Janus Grid的LoadingRowSelectionChanged事件。

这是一个示例代码:(在这里,我检查要除以2的特定列的值)

代码语言:javascript
复制
    private void grdEx_LoadingRow(object sender, Janus.Windows.GridEX.RowLoadEventArgs e)
    {
        if (Convert.ToInt32(e.Row.Cells["ID"].Value) % 2 == 0)
        {
            e.Row.RowStyle = new GridEXFormatStyle(e.Row.Table.RowFormatStyle);
            e.Row.RowStyle.BackColor = Color.Gray;
        }
    }

    private void grdEx_SelectionChanged(object sender, EventArgs e)
    {
        if (Convert.ToInt32(grdEx.GetValue("ID")) % 2 == 0)
        {
            if (grdEx.Row >= 0)
            {
                if (grdEx.Row == grdEx.RowCount - 1)
                    grdEx.Row = grdEx.Row - 1;
                else
                    grdEx.Row = grdEx.Row + 1;
            }
        }
    }
票数 0
EN

Stack Overflow用户

发布于 2017-10-30 16:50:06

根据复选框列的不同,只需查看示例代码:

代码语言:javascript
复制
 private void grdEX1_FormattingRow(object sender, RowLoadEventArgs e)
 {
        if (e.Row.RowIndex > -1 && e.Row.RowIndex < grdEX1.RowCount)
        {
            for (int i = 0; i < grdEX1.RootTable.Columns.Count; i++)
            {
                if (!Convert.ToBoolean(e.Row.Cells["checkboxCol"].Value))//checked So editable
                {
                    e.Row.Cells[i].FormatStyle = new GridEXFormatStyle() { BackColor = Color.LightGray };
                }
                else
                {
                    e.Row.Cells[i].FormatStyle = null;
                }
            }
        }
    }

要在未选中行时阻止编辑,请执行以下操作:

代码语言:javascript
复制
private void grdEX1_EditingCell(object sender, EditingCellEventArgs e)
{
     if(!Convert.ToBoolean(grdEX1.GetValue("checkboxCol"))) //not checked 
    {
        e.Cancel = true;
        return;
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13099969

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档