We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

image opacity

Any idea how to set an image''s opacity in QueryCellStyleInfo?

Thanks,

eric

1 Reply

AD Administrator Syncfusion Team September 12, 2006 06:26 AM UTC

Hi Eric,

Try this code to set the optacity of the BackgroundImage in a cell.

Rectangle rect = new Rectangle(0,0,200,200);
private void gridQueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if( e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record)
{
img = Image.FromFile("image.jpg");

//Create the Graphics object for the image.
Graphics gra = Graphics.FromImage(img);
ImageAttributes ia =new ImageAttributes();

//set the Gamma factor for optacity.
if( e.TableCellIdentity.ColIndex %2 == 0 )
ia.SetGamma(0.1f);

//Draw the Optacity image to imagegraphics.
gra.DrawImage(img,rect ,0,0,200,200,GraphicsUnit.Pixel,ia);

//set the image as BackgroundImage.
e.Style.BackgroundImage = img;
}
}

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/ImageOpacityGrid_9329fe03.zip

Let me know if this helps.
Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon