Kurve in pictureBox zeichnen

Hallo!

Ich habe folgendes Problem:
Per Paint-EventHandler will ich über die Funktion DrawBezier eine Kurve in eine PictureBox zeichnen. Leider erscheint die Kurve nicht in meiner PictureBox! Was ich mache falsch?
Code:
//...
		private void InitializeComponent()
		{
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.SuspendLayout();
			// 
			// pictureBox1
			// 
			this.pictureBox1.BackColor = System.Drawing.SystemColors.ControlLightLight;
			this.pictureBox1.Location = new System.Drawing.Point(64, 48);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(160, 152);
			this.pictureBox1.TabIndex = 0;
			this.pictureBox1.TabStop = false;
			this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.Paint_picBox);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(264, 246);
			this.Controls.Add(this.pictureBox1);
			this.Name = "Form1";
			this.Text = "Form1";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.ResumeLayout(false);

		}

//...

	private void Paint_picBox(object sender, System.Windows.Forms.PaintEventArgs pe)
		{
			Pen blackPen = new Pen(Color.Black,1);
			
			float freq_StartX = 48.0F;
			float freq_StartY = 200.0F;
			
			float dB1_X = 150.0F;
			float dB1_Y = 134.0F;

			float dB2_X = 170.0F;
			float dB2_Y = 154.0F;

			float freq_StopX = 360.0F;
			float freq_StopY = 200.0F;

			pe.Graphics.DrawBezier(blackPen,freq_StartX,freq_StartY,dB1_X,dB1_Y,dB2_X,dB2_Y,freq_StopX,freq_StopY);
		}

		}

Danke für Hilfe

MfG
MC
 
Hallo!


Du musst auf die Picturebox malen. Dazu dieser Code:

Code:
' Get handle to pictureBox1.

Dim hwnd As New IntPtr()

hwnd = pictureBox1

' Create new graphics object using handle to window.

Dim newGraphics As Graphics = Graphics.FromHwnd(hwnd)

' Draw rectangle to screen.

newGraphics.DrawRectangle(New Pen(Color.Red, 3), 0, 0, 200, 100)

' Dispose of new graphics.

newGraphics.Dispose()

Weitere Infos zum zeichnen findest du in der msdn-Library im Bereich System.Drawing-Namespace in der .NET-Framework-Referenz.
 

Neue Beiträge

Zurück