Skip to main content Skip to footer

How to disable data bound image using C1PictureBox

The C1PictureBox control is a data bound control which shows picture images stored in a data source field, derived from System.Windows.Forms.PictureBox. Though it has 'Enabled' property' setting this property to False does not have any effect on the image being displayed. You can make the image look disabled by drawing a semi-transparent gray rectangle over the image using the Paint event.

The code looks as follows :

private void c1PictureBox1_Paint(object sender, PaintEventArgs e)  
{  
    if (!c1PictureBox1.Enabled)  
    {  
        using (Brush fBrush = new SolidBrush(Color.FromArgb(171, 71, 71, 71)))  
            e.Graphics.FillRectangle(fBrush, this.c1PictureBox1.ClientRectangle);  
    }  
}