Posted 21 October 2020, 2:20 am EST
Hello,
I’m trying to vertically center an image in a spancell.
How can I do that?
I’ve tried to set the verticalalignment property of each cell to center but image does only appear in the first cell.
Forums Home / Spread / Spread for WinForms
Posted by: fsegui on 21 October 2020, 2:20 am EST
Posted 21 October 2020, 2:20 am EST
Hello,
I’m trying to vertically center an image in a spancell.
How can I do that?
I’ve tried to set the verticalalignment property of each cell to center but image does only appear in the first cell.
Posted 21 October 2020, 7:19 pm EST
Hello,
In case of cell spanning, the cell style for the upper left corner of the span is used for the whole span., as if you are stretching that corner cell to cover the other cells in the span.
So, you are suggested to make sure the VerticalAlignment of the top left span cell is set to Center.
I used the following code and the image shows at span’s vertically center:```
fpSpread1.ActiveSheet.Cells[0, 0].Text = “These cells are spanned.”;
fpSpread1.ActiveSheet.AddSpanCell(0, 0, 10, 5);
fpSpread1.ActiveSheet.Cells[0, 0].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
fpSpread1.ActiveSheet.Cells[0, 0].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
FarPoint.Win.Spread.CellType.ImageCellType imgct = new FarPoint.Win.Spread.CellType.ImageCellType();
System.Drawing.Image image = Properties.Resources.TestImage;
imgct.Style = FarPoint.Win.RenderStyle.Normal;
fpSpread1.Sheets[0].Cells[0, 0, 10, 5].CellType = imgct;
fpSpread1.Sheets[0].Cells[0, 0].Value = image;
Ruchir
[img]https://gccontent.blob.core.windows.net/forum-uploads/file-4dad3560-2589-4520-ab36-91af3761f907.PNG[/img]
Posted 21 October 2020, 11:49 pm EST
Hello,
Thanks for your reply. I was not applying the imagecelltype to the span cell but to each cell. Now it’s working fine.