110,533
社区成员
发帖
与我相关
我的任务
分享
private static int GroupId = 1; int Column = 4; int Row = 1;
private static int x1 = 0; int x2 = 120; int x3 = 140;
private static int y1 = 0; int y2 = 0; int y3 = 0;
public Form3()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
PictureBox p = new PictureBox();
p.BorderStyle = BorderStyle.FixedSingle;
p.Image = objImage; //Image.FromFile(@"D:\wubw\AutoCity.UploadImages\AutoCity.UploadImages\bin\Debug\0.jpg");
p.Name = "pbx" + GroupId;
this.panel1.Controls.Add(p);
TextBox t = new TextBox();
t.Name = "tb" + GroupId;
panel1.Controls.Add(t);
Button b = new Button();
b.Name = "bt" + GroupId;
b.Text = "浏览";
b.MouseDown += new MouseEventHandler(this.ButtonArray_OnClick);
panel1.Controls.Add(b);
Button del = new Button();
del.Name = "del" + GroupId;
del.Text = "删除";
del.MouseDown += new MouseEventHandler(this.ButtonArraydel_OnClick);
panel1.Controls.Add(del);
SetControlsLocation();
GroupId++;
}
private bool ThumbnailCallBack()
{
return false;
}
private void SetControlsLocation()
{
this.panel1.Hide();
int btWidth = 45; int pbxWidth = 150;
int w = 0;
//int p = GroupId % Column;
//if (GroupId % Column == 0)
//{
// x1 += 180;
// y1 = 0;
//}
foreach (Control tmpCtr in panel1.Controls)
{
w++;
if (tmpCtr.Text == "添加新图片")
{
continue;
}
if (tmpCtr.Name == "pbx" + GroupId)
{
tmpCtr.Top = x1;
tmpCtr.Left = y1;
tmpCtr.Width = pbxWidth;
tmpCtr.Height = 120;
}
if (tmpCtr.Name == "tb" + GroupId)
{
tmpCtr.Top = x2;
tmpCtr.Left = y2;
tmpCtr.Width = pbxWidth;
}
if (tmpCtr.Name == "bt" + GroupId)
{
tmpCtr.Top = x3;
tmpCtr.Left = y3;
tmpCtr.Height = 25;
tmpCtr.Width = btWidth;
}
if (tmpCtr.Name == "del" + GroupId)
{
tmpCtr.Top = x3;
tmpCtr.Left = y3+btWidth;
tmpCtr.Height = 25;
tmpCtr.Width = btWidth;
}
tmpCtr.BringToFront();
}
y1 += pbxWidth + 5;
y2 += pbxWidth + 5;
y3 += pbxWidth + 5;
button1.Left = y1 + 50;
button1.Top = x1;
if ((GroupId % Column) == 0 && GroupId/Column == Row)
{
x1 += 180; x2 += 180; x3 += 180;
y1 = 0; y2 = 0; y3 = 0;
Row++;
}
//MessageBox.Show(x1.ToString());
this.panel1.Show();
}