I want to draw in a panel with this method:
protected override void InitOutput(object output)
{
if (output is Control)
{
Control c = (Control)output;
g.FillRectangle(hb, 7, 10, 30 - 19, 5);
...
}
With a text I can do this:
protected override void InitOutput(object output)
{
if (output is Control)
{
Control c = (Control)output;
lbl.Name = "lbl";
lbl.Size = new System.Drawing.Size(10, 10);
lbl.TabIndex = 5;
lbl.Text = "test";
panel.Location = new System.Drawing.Point(1, 1);
panel.Name = "panelSys";
panel.Size = new System.Drawing.Size(20, 20);
panel.TabIndex = 5;
panel.Controls.Add(lbl);
c.Controls.Add(panelSys);
}
Hope you can help me thanks
Drawing to controls Should be done by adding a 'Paint' event to the control and then draw inside this event. You will get a 'Graphics' object through the EventArgs. Then you can force a draw of the control using the 'Invalidate' method of the control. Also Windows will call the Paint event on ita own sometimes.
Alternatively you can also create a normale using 'Bitmap.Create'. Draw to that and then assign it to a Picture control.
I am not sure why do you need InitOtuput function but if you want to draw from it you could do it like this:
Additionaly you don't need to use label to draw text u can draw it using Graphics.DrawSting