Hi all,
I have to develop Windows C# application, using Visual Studio 2008. It have dynamical to create pictureboxes, to add image in it, and to move picturebox to some X position.
So, I have windows form with next components:
- button, with title "Add new"
- Combobox
- Text Field
- another button, with title "Set position".
Also, I have one folder with several images (png files) in it.
So, when I click on first button it have to create new PictureBox, and to add name of Picturebox into ComboBox.
After that, I can choose one PictureBox from it's list in combobox, and to move it to X position I entered into TextBox.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DynamicComponents
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int imgCounter = 0;
/*
* Create pictureboxes and add images
*/
private void button1_Click(object sender, EventArgs e)
{
PictureBox pb = new PictureBox();
pb.Name = "PictureBox" + (++imgCounter);
pb.Size = new Size(100, 100);
pb.Image = Image.FromFile(@"C:\slike\" + imgCounter.ToString() + ".png");
this.Controls.Add(pb);
comboBox1.Items.Add(pb.Name);
}
/*
* Move PictureBox on X position I entered into textfield
* */
private void button2_Click(object sender, EventArgs e)
{
// help!!!
}
}
}