How to put an image behind several rows ?

Posted by: jeremie-baldy on 8 September 2017, 2:40 pm EST

  • Posted 8 September 2017, 2:40 pm EST

    Hi !

    I use V4 farpoint winform

    In Header of my sheet, I have 4 rows with only one HeaderSpanCell per line.

    I wish put an image in background of this rows.

    with border transparent, Is it possible ?

     

    I try:

                FarPoint.Win.Spread.CellType.RichTextCellType rtf = new FarPoint.Win.Spread.CellType.RichTextCellType();
                rtf.BackgroundImage = new Picture(Resource.banner);
                rtf.BackgroundImage.AlignHorz = FarPoint.Win.HorizontalAlignment.Right;
                sheet.ColumnHeader.Cells[0, 0, 3, 0].CellType = rtf; // cut image on each row

     

    or

    Spread.BackgroundImage = Resource.banner; // does nothing

     

    Without success :)

     

    Thanks

  • Replied 8 September 2017, 2:40 pm EST

    Spread.BackgroundImage = Resource.banner;

    works with HeaderCell transparent backcolor / border.

     

    But is it possible to  set horizontal aligment at right ? BackgroundImage.AlignHorz = FarPoint.Win.HorizontalAlignment.Right;

     

    alternatively, i will use Crop Image... but how to get the With of first HeaderCell ?

  • Replied 8 September 2017, 2:40 pm EST

    If i use spread resize event:

    Spread.Resize += new EventHandler(Spread_Resize);

            private void SetSpreadBanner(FpSpread spread)
            {
                int width = spread.Size.Width;
                Spread.BackgroundImage = CropBitmap(Resource.SpreadBanner, Resource.SpreadBanner.Width - width, 0, width, Resource.SpreadBanner.Height);
                Spread.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
            }

            public Bitmap CropBitmap(Bitmap bitmap, int cropX, int cropY, int cropWidth, int cropHeight)
            {
                if (bitmap == null) return null;
                Rectangle rect = new Rectangle(cropX, cropY, cropWidth, cropHeight);
                return bitmap.Clone(rect, bitmap.PixelFormat);

            }

     

    The blank white margin false results of size image

  • Replied 8 September 2017, 2:40 pm EST

    Hello,

    Here is the code for the required functionality wherein image is right aligned in the background and text is also shown:-

                fpSpread1.ActiveSheet.ColumnHeader.RowCount = 4;
                fpSpread1.ActiveSheet.AddColumnHeaderSpanCell(0, 0, 1, 3);
                fpSpread1.ActiveSheet.AddColumnHeaderSpanCell(1, 0, 1, 3);
                fpSpread1.ActiveSheet.AddColumnHeaderSpanCell(2, 0, 1, 3);
                FarPoint.Win.Spread.CellType.RichTextCellType rtf = new FarPoint.Win.Spread.CellType.RichTextCellType();
                rtf.BackgroundImage = new FarPoint.Win.Picture(Image.FromFile(@"C:\Users\Public\Pictures\Sample Pictures\thumb_small_abacus.png"), FarPoint.Win.RenderStyle.Normal);
                rtf.BackgroundImage.AlignHorz = FarPoint.Win.HorizontalAlignment.Right;
                fpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].BackColor = Color.Transparent;
                fpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].CellType = rtf;
                fpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].Text = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
    {\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22 CellText.\par
    }";
                fpSpread1.Sheets[0].ColumnHeader.Cells[1, 0].BackColor = Color.Transparent;
                fpSpread1.Sheets[0].ColumnHeader.Cells[1, 0].CellType = rtf;
                fpSpread1.Sheets[0].ColumnHeader.Cells[1, 0].Text = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
    {\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22 CellText.\par
    }";
                fpSpread1.Sheets[0].ColumnHeader.Cells[2, 0].BackColor = Color.Transparent;
                fpSpread1.Sheets[0].ColumnHeader.Cells[2, 0].CellType = rtf;
                fpSpread1.Sheets[0].ColumnHeader.Cells[2, 0].Text = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
    {\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22 CellText.\par
    }";

    Hope this will help you. Thanks.

Need extra support?

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

Learn More

Forum Channels