【问题标题】:Janus 4 GridEx disable rowsJanus 4 GridEx 禁用行
【发布时间】:2012-10-27 11:58:14
【问题描述】:

我有一个包含复选框列的 Janus 4 GridEx 控件。 我需要能够根据特定列的值禁用某些行(即使它们不可选择/变灰)。网格的数据是从数据库中加载的。

任何帮助将不胜感激。

【问题讨论】:

    标签: vb.net janus gridex


    【解决方案1】:

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

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

        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;
                }
            }
        }
    

    【讨论】:

      【解决方案2】:

      取决于复选框列,只需查看示例代码:

       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;
                      }
                  }
              }
          }
      

      如果未选中该行,则防止编辑:

      private void grdEX1_EditingCell(object sender, EditingCellEventArgs e)
      {
           if(!Convert.ToBoolean(grdEX1.GetValue("checkboxCol"))) //not checked 
          {
              e.Cancel = true;
              return;
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多