Hello Alex,
For changing the appearance of disabled C1FlexGrid, you need to create your CellStyle that looks similar to the standard disabled controls and apply the same to Grid cells as follows:
[csharp]private void Form1_Load(object sender, EventArgs e)
{
c1FlexGrid1.DataSource = dt;
c1FlexGrid1.Enabled = false;
disabledStyle = c1FlexGrid1.Styles.Add("Disabled");
disabledStyle.BackColor = Color.FromArgb(Convert.ToByte(240), Convert.ToByte(240), Convert.ToByte(240));
disabledStyle.ForeColor = Color.DarkGray;
disabledStyle.Border.Style = BorderStyleEnum.Flat;
disabledStyle.Border.Color = Color.LightGray;
CellRange rng = default(CellRange);
rng = c1FlexGrid1.GetCellRange(1, 1, c1FlexGrid1.Rows.Count - 1, c1FlexGrid1.Cols.Count - 1);
rng.Style = disabledStyle;
}
private void c1FlexGrid1_EnabledChanged(object sender, EventArgs e)
{
if (!c1FlexGrid1.Enabled)
{
c1FlexGrid1.VisualStyle = VisualStyle.Custom;
CellRange rng = default(CellRange);
rng = c1FlexGrid1.GetCellRange(1, 1, c1FlexGrid1.Rows.Count - 1, c1FlexGrid1.Cols.Count - 1);
rng.Style = disabledStyle;
}
else
{
//apply original style or your own style.
c1FlexGrid1.VisualStyle = VisualStyle.System;
CellRange rng = default(CellRange);
rng = c1FlexGrid1.GetCellRange(1, 1, c1FlexGrid1.Rows.Count - 1, c1FlexGrid1.Cols.Count - 1);
rng.Style = c1FlexGrid1.Styles.Normal;
}
}[/csharp]
You may then disable/enable the grid using CheckBox as follows:
[csharp]private void c1CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if(c1FlexGrid1.Enabled)
{
c1FlexGrid1.Enabled = false;
}
else
{
c1FlexGrid1.Enabled = true;
}
}[/csharp]
I have also attached a sample application for your reference.
Thanks,
Ruchir Agarwal
2017/08/prj_DisabledFlexGrid.zip