Works fine for me.  What context are you using that code in?  Here's what
I'm doing:

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
    e.Graphics.DrawEllipse(Pens.Blue, 10, 10, 300, 300);
}

This is in the MDI child form class.  I just created a perfectly normal
form.  Here's how I associated it with the parent:

private void menuItem5_Click(object sender, System.EventArgs e)
{
    ChildForm cf = new ChildForm();
    cf.MdiParent = this;
    cf.Show();
}


Admittedly I can't draw anything in the MDI parent - this resolutely insists
on being dark grey.  Apparently my OnPaint is getting called, but the dark
grey seems to get blatted over that.

Looking at Form.OnPaint in ILDASM it's not hard to see why - if the form has
its IsMdiContainer property set to true, it calls FillRectangle using
SystemColors.AppWorkspace and ClientRectangle.  It does this *after* it has
called OnPaint.  I've no idea why it bothers calling OnPaint in this case,
since it always draws straight over whatever has been drawn...

So you can't draw anything in an MDI parent, but your code works as is in an
MDI child when I try it.


--
Ian Griffiths
DevelopMentor

----- Original Message -----
From: "Richard Kucia" [EMAIL PROTECTED]

> The following line of code works just fine in a WinForms .Paint event:
>
>     e.Graphics.DrawEllipse(Pens.Blue, 10, 10, 300, 300)
>
> unless the form is a MDI parent or child (in which case, nothing
> appears). How do I draw on these form types?

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to