0
我有一個Janus 4 GridEx控件,其中包含一個複選框列。 根據特定列的值,我需要能夠禁用某些行(即使它們不可選/灰顯)。網格的數據從數據庫加載。Janus 4 GridEx禁用行
任何幫助,將不勝感激。
我有一個Janus 4 GridEx控件,其中包含一個複選框列。 根據特定列的值,我需要能夠禁用某些行(即使它們不可選/灰顯)。網格的數據從數據庫加載。Janus 4 GridEx禁用行
任何幫助,將不勝感激。
您必須利用Janus Grid的LoadingRow
和SelectionChanged
事件。
這是一個示例代碼:(這裏我正在檢查的特定列的值除以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;
}
}
}
,只看到示例代碼:
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;
}
}