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

    <p>Hi ! </p><p>I use V4 farpoint winform <br></p><p>In Header of my sheet, I have 4 rows with only one HeaderSpanCell per line.</p><p>I wish put an image in background of this rows.</p><p>with border transparent, Is it possible ?</p><p> </p><p>I try:</p><p>            FarPoint.Win.Spread.CellType.RichTextCellType rtf = new FarPoint.Win.Spread.CellType.RichTextCellType();<br>            rtf.BackgroundImage = new Picture(Resource.banner);<br>            rtf.BackgroundImage.AlignHorz = FarPoint.Win.HorizontalAlignment.Right;<br>            sheet.ColumnHeader.Cells[0, 0, 3, 0].CellType = rtf; // cut image on each row<br></p><p> </p><p>or</p><p>Spread.BackgroundImage = Resource.banner; // <span id="result_box" class="short_text"><span class="hps">does nothing</span></span></p><p> </p><p>Without success :)</p><p> </p><p>Thanks <br></p>
  • Replied 8 September 2017, 2:40 pm EST

    <p>Spread.BackgroundImage = Resource.banner; <span id="result_box" class="short_text"><span class="hps"></span></span></p><p>works with HeaderCell transparent backcolor / border.</p><p> </p><p>But is it possible to  set horizontal aligment at right ? BackgroundImage.AlignHorz = FarPoint.Win.HorizontalAlignment.Right;</p><p> </p><p>alternatively, i will use Crop Image... but how to get the With of first HeaderCell ?<br></p>
  • Replied 8 September 2017, 2:40 pm EST

    <p>If i use spread resize event:<br></p><p>Spread.Resize += new EventHandler(Spread_Resize); </p><p>        private void SetSpreadBanner(FpSpread spread)<br>        {<br>            int width = spread.Size.Width;<br>            Spread.BackgroundImage = CropBitmap(Resource.SpreadBanner, Resource.SpreadBanner.Width - width, 0, width, Resource.SpreadBanner.Height);<br>            Spread.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;<br>        }<br><br>        public Bitmap CropBitmap(Bitmap bitmap, int cropX, int cropY, int cropWidth, int cropHeight)<br>        {<br>            if (bitmap == null) return null;<br>            Rectangle rect = new Rectangle(cropX, cropY, cropWidth, cropHeight);<br>            return bitmap.Clone(rect, bitmap.PixelFormat);<br><br>        }</p><p> </p><p>The blank white margin <span id="result_box" class="short_text"><span class="hps">false</span> <span class="hps">results of size image</span></span> </p>
  • Replied 8 September 2017, 2:40 pm EST

    <p>Hello,</p><p>Here is the code for the required functionality wherein image is right aligned in the background and text is also shown:-</p><blockquote><p>            fpSpread1.ActiveSheet.ColumnHeader.RowCount = 4;<br>            fpSpread1.ActiveSheet.AddColumnHeaderSpanCell(0, 0, 1, 3);<br>            fpSpread1.ActiveSheet.AddColumnHeaderSpanCell(1, 0, 1, 3);<br>            fpSpread1.ActiveSheet.AddColumnHeaderSpanCell(2, 0, 1, 3);<br>            FarPoint.Win.Spread.CellType.RichTextCellType rtf = new FarPoint.Win.Spread.CellType.RichTextCellType();<br>            rtf.BackgroundImage = new FarPoint.Win.Picture(Image.FromFile(@"C:\Users\Public\Pictures\Sample Pictures\thumb_small_abacus.png"), FarPoint.Win.RenderStyle.Normal);<br>            rtf.BackgroundImage.AlignHorz = FarPoint.Win.HorizontalAlignment.Right;<br>            fpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].BackColor = Color.Transparent;<br>            fpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].CellType = rtf;<br>            fpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].Text = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}<br>{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22 CellText.\par<br>}";<br>            fpSpread1.Sheets[0].ColumnHeader.Cells[1, 0].BackColor = Color.Transparent;<br>            fpSpread1.Sheets[0].ColumnHeader.Cells[1, 0].CellType = rtf;<br>            fpSpread1.Sheets[0].ColumnHeader.Cells[1, 0].Text = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}<br>{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22 CellText.\par<br>}";<br>            fpSpread1.Sheets[0].ColumnHeader.Cells[2, 0].BackColor = Color.Transparent;<br>            fpSpread1.Sheets[0].ColumnHeader.Cells[2, 0].CellType = rtf;<br>            fpSpread1.Sheets[0].ColumnHeader.Cells[2, 0].Text = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}<br>{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22 CellText.\par<br>}"; </p></blockquote><p>Hope this will help you. Thanks.<br></p>
Need extra support?

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

Learn More

Forum Channels