|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Draw ellipse with specify x,y,width, heightinput argument in C# .net (Visual Studio 2005). It seem it will not draw for me. What am I missing? See the code below, thanks. //CODE using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { draw(10, 20, 20, 50); draw(50, 80, 50, 150); } private void draw(int x1, int y1, int w, int h) { Graphics g = this.CreateGraphics(); g.FillEllipse(Brushes.Blue, x1, y1, w, h); } } } I got it to work but when I added in the GroupBox.
It show in the back and group is over it. Is there a way set it to back or show the drawing the group box as well? Here is the update code: ///code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; //using System.Media; namespace test { public partial class Form1 : Form { public Form1() { InitializeComponent(); draw(50, 80, 50, 150); } private void Form1_Load(object sender, EventArgs e) { draw(10, 20, 20, 50); //SoundPlayer simpleSound = new SoundPlayer(@"C: \911.wav"); // simpleSound.Play(); } private void draw(int x1, int y1, int w, int h) { Graphics dc = this.CreateGraphics(); this.Show(); dc.FillEllipse(Brushes.Blue, x1, y1, w, h); Pen RedPen = new Pen(Color.Red, 2); dc.DrawEllipse(RedPen, x1, y1, w, h); } private void groupBox1_Enter(object sender, EventArgs e) { } } } On 2007-11-28 21:46:16 -0800, Slickuser <slick.us***@gmail.com> said:
> I got it to work but when I added in the GroupBox. You are doing it wrong. You cannot just draw whenever you want. You > > It show in the back and group is over it. Is there a way set it to > back or show the drawing the group box as well? need to override the OnPaint() method, or subscribe to the Paint event, and only draw there. Search on those names ("OnPaint" and "Paint") in this newsgroup for a number of related threads, including one that is as recent as today and includes very specific details regarding the correct way to draw in a form. Pete On Nov 29, 2:22 am, Peter Duniho <NpOeStPe***@NnOwSlPiAnMk.com> wrote:
Show quote > On 2007-11-28 21:46:16 -0800, Slickuser <slick.us***@gmail.com> said: Or you can try this link and look at the number 1 FAQ:> > > I got it to work but when I added in the GroupBox. > > > It show in the back and group is over it. Is there a way set it to > > back or show the drawing the group box as well? > > You are doing it wrong. You cannot just draw whenever you want. You > need to override the OnPaint() method, or subscribe to the Paint event, > and only draw there. > > Search on those names ("OnPaint" and "Paint") in this newsgroup for a > number of related threads, including one that is as recent as today and > includes very specific details regarding the correct way to draw in a > form. > > Pete http://www.bobpowell.net/faqmain.htm Chris Yes Bob's pages are an excellent way of learning. Thats were I learnt how to
do my buttons MikeY Show quote "Chris Dunaway" <dunaw***@gmail.com> wrote in message news:3d8f45fb-8027-4941-8f6b-3c8a0818c1cc@x69g2000hsx.googlegroups.com... > On Nov 29, 2:22 am, Peter Duniho <NpOeStPe***@NnOwSlPiAnMk.com> wrote: >> On 2007-11-28 21:46:16 -0800, Slickuser <slick.us***@gmail.com> said: >> >> > I got it to work but when I added in the GroupBox. >> >> > It show in the back and group is over it. Is there a way set it to >> > back or show the drawing the group box as well? >> >> You are doing it wrong. You cannot just draw whenever you want. You >> need to override the OnPaint() method, or subscribe to the Paint event, >> and only draw there. >> >> Search on those names ("OnPaint" and "Paint") in this newsgroup for a >> number of related threads, including one that is as recent as today and >> includes very specific details regarding the correct way to draw in a >> form. >> >> Pete > > Or you can try this link and look at the number 1 FAQ: > > http://www.bobpowell.net/faqmain.htm > > Chris > |
|||||||||||||||||||||||