Unable to use background image in header cells

Posted by: dheydt on 8 September 2017, 3:26 pm EST

  • Posted 8 September 2017, 3:26 pm EST

    Trying to use an image for the background of the header cells. Here is the code am using but the background does not have the image.

    FarpointSpreadControl.VisualStyles = FarPoint.Win.VisualStyles.Off;

    //Must clone the current skin in order to change it!
    SpreadSkin mySkin = (SpreadSkin)FarpointSpreadControl.Skin.Clone();

    FarPoint.Win.Spread.CellType.ColumnHeaderRenderer cHeaderRenderer = new FarPoint.Win.Spread.CellType.ColumnHeaderRenderer();
    if (headerImage != null)
    {
    cHeaderRenderer.BackgroundImage = headerImage;
    cHeaderRenderer.BackgroundImageLayout = ImageLayout.Stretch;
    cHeaderRenderer.UseVisualStyleBackColor = false;
    cHeaderRenderer.Picture = headerImage;
    cHeaderRenderer.BackColor = Color.Transparent;
    }
    mySkin.ColumnHeaderDefaultStyle.Renderer = cHeaderRenderer;
    mySkin.Apply(FarpointSpreadControl);

    Note that this is the latest version of many attempts I have made to try and figure this out.
  • Replied 8 September 2017, 3:26 pm EST

    Hello,

    We are unable to replicate the issue wherein image is rendering correctly in header using your code and also using my code of ImageCellType.

    // With Image CellType
    System.Drawing.Image image = System.Drawing.Image.FromFile(@"..\..\Images\\we.jpg");
    FarPoint.Win.Spread.CellType.ImageCellType ct = new FarPoint.Win.Spread.CellType.ImageCellType();
    ct.Style = FarPoint.Win.RenderStyle.Stretch;
    ct.TransparencyColor = Color.Black;
    ct.TransparencyTolerance = 20;
    fpSpread1.Sheets[0].ColumnHeader.Columns[0].CellType = ct;
    fpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].Value = image;

    /////////////////////////////////////////////////////////

    // Your code with Skin
    fpSpread1.VisualStyles = FarPoint.Win.VisualStyles.Off;

    //Must clone the current skin in order to change it!
    SpreadSkin mySkin = (SpreadSkin)fpSpread1.Skin.Clone();

    System.Drawing.Image headerImage = System.Drawing.Image.FromFile(@"..\..\Images\\we.jpg");
    FarPoint.Win.Spread.CellType.ColumnHeaderRenderer cHeaderRenderer = new FarPoint.Win.Spread.CellType.ColumnHeaderRenderer();
    if (headerImage != null)
    {
    cHeaderRenderer.BackgroundImage = headerImage;
    cHeaderRenderer.BackgroundImageLayout = ImageLayout.Stretch;
    cHeaderRenderer.UseVisualStyleBackColor = false;
    cHeaderRenderer.Picture = headerImage;
    cHeaderRenderer.BackColor = Color.Transparent;
    }
    mySkin.ColumnHeaderDefaultStyle.Renderer = cHeaderRenderer;
    mySkin.Apply(fpSpread1);


    Hope it helps. Please have a look at attached sample for more clarity.

    Thanks,
    Reeva
    2017/06/HeaderImage.zip
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels