Hi,
kann mir jemand sagen, wie ich die größe einer Picturebox zur Laufzeit ändern kann.
Mein Code ist bis jetzt folgender:
Zudem will ich den Pfad des Images aus einer xml auslesen. Das auslesen funktioniert auch wunderbar. Aber wie schreibe ich denn dann in der picturebox hin das der ausgelesene Pfad genommen werden soll? Ich habe es so probiert aber das funktioniert nicht.
Kann mir jemand helfen?
Lieben Dank
sailer
kann mir jemand sagen, wie ich die größe einer Picturebox zur Laufzeit ändern kann.
Mein Code ist bis jetzt folgender:
Code:
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Geraet));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.name = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(82, 41);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.mouseDown);
this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.mouseMove);
this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.mouseUp);
//
// name
//
this.name.AutoSize = true;
this.name.Location = new System.Drawing.Point(21, 13);
this.name.Name = "name";
this.name.Size = new System.Drawing.Size(41, 13);
this.name.TabIndex = 1;
this.name.Text = "[Name]";
this.name.MouseDown += new System.Windows.Forms.MouseEventHandler(this.mouseDown);
this.name.MouseMove += new System.Windows.Forms.MouseEventHandler(this.mouseMove);
this.name.MouseUp += new System.Windows.Forms.MouseEventHandler(this.mouseUp);
//
// Geraet
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.name);
this.Controls.Add(this.pictureBox1);
this.Name = "Geraet";
this.Size = new System.Drawing.Size(85, 44);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.mouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.mouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.mouseUp);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private void mouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMouseDown = true;
beginMovingPointMouse = new Point(e.X, e.Y);
beginMovingPointControl = this.Location;
}
}
private void mouseMove(object sender, MouseEventArgs e)
{
if (isMouseDown)
{
int deltaX = e.X - beginMovingPointMouse.X;
int deltaY = e.Y - beginMovingPointMouse.Y;
this.Left += deltaX;
this.Top += deltaY;
}
}
private void mouseUp(object sender, MouseEventArgs e)
{
isMouseDown = false;
beginMovingPointMouse = Point.Empty;
beginMovingPointControl = Point.Empty;
}
Zudem will ich den Pfad des Images aus einer xml auslesen. Das auslesen funktioniert auch wunderbar. Aber wie schreibe ich denn dann in der picturebox hin das der ausgelesene Pfad genommen werden soll? Ich habe es so probiert aber das funktioniert nicht.
Code:
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject(pfad)));
Kann mir jemand helfen?
Lieben Dank
sailer