guys, i am a beginner.
afaik it seems to be a mixup in the English language.
could you please advise what is wrong with using the TShape code i posted?
There is absolutely nothing wrong with using a TShape to draw/show a line. If it works for you then perfect
what are the benefits of creating a new panel component if i can use TShape?
Depending on your requirements it offers more flexibility, such as drawing horizontal, cross, or vertical lines (in fact you can draw anything what your heart desires).
DO note that it is not required to create a new component. As Lainz already wrote you can use the OnPaint method of TPanel and draw your line (or whatever shape you wish).
However, when howardpc asked:
Does direct drawing on the form/panel's Canvas using Canvas.Line() not work for you?
You replied with:
i do not know how to draw on TPanel as this component does not expose the Canvas.Line().
And that is imho a misunderstanding from your side.
I showed you the 'path' to reach Canvas.Line method. Something like MyPanel1.Canvas.Line(1,1,200,200) should do the trick. Your claim that Canvas.Line is not exposed is therefor wrong. Nothing wrong with that, but that is what i tried to explain.
However, it is better to use the
OnPaint event to do your drawing, which makes the lien more permanent. That does not require you to create a new component. Just for you to add the OnPaint Event in the object inspector, and start drawing in code