Draw Line/Shape in FarPoint FpSpread

If you worked with FarPoint Spread, you know that it uses conventions and APIs entirely different from what’s used in normal Winforms. When it comes to drawing inside a FarPoint spread, CreateGraphics will definitely not work. If only FarPoint made their documentations Google-friendly, you will find that there are in fact APIs specifically made for drawing.

'Draws a horizontal line
Dim line As New FarPoint.Win.Spread.DrawingSpace.LineShape
line.Thickness = 3
line.Width = x
line.Height = 1 'if you don't specify it, the line will do weird things
line.Top = x
line.Left = x
line.ShapeOutlineColor = Color.FromArgb(x, x, x)
fpspread.ActiveSheet.AddShape(line)

Please note that the line.Top is calculated from the top of the header. If you scroll down, it’s still calculated from the header (which may be screens away). Use ActiveSheet.AddShape(line, row, column) to set a starting reference point.

No related posts.