In event handler of Form Load, I have the following code
Panel pHText = new Panel();
Font myFont = new Font("Arial", 14);
pHText.Location=new Point(10,10);
pHText.Size=new Size(200,200);
pHText.BackColor = Color.White;
Graphics g = pHText.CreateGraphics();
g.DrawLine(new Pen(Color.Black), 0, 0, 10, 10);
g.DrawString("text", myFont, Brushes.Blue, 10, 10);
Controls.Add(pHText);
The white Panel is shown in the form, but those drawing of line and string are not.
this code will go in your form load event
add paint event named
paintingUrCtr.