我在一个事件上生成了几个面板,在这些面板中我有一个按钮,它将删除该特定面板。现在我想在删除没有间隙的面板时移动其他面板。我的面板生成功能是....
public void generate_editpanel(string c)
{
int i, j, k, b;
int m, n;
//Bitmap bmp = drawled(16, 16, Color.Black, Color.White);
//imglst.Images.Add(bmp);
for (i = 0; i <= 20; i++)
{
epnl[i] = new Panel();
epnl[i].Visible = false;
epnl[i].Enabled = true;
epnl[i].Name = "epnl" + c;
epnl[i].Location = new System.Drawing.Point(x, 0);
epnl[i].Width = 260;
epnl[i].Height = 173;
epnl[i].BorderStyle = BorderStyle.Fixed3D;
EditPanel.Controls.Add(epnl[i]);
grid[i] = new DataGridView();
cellstl = new DataGridViewCellStyle();
grid[i].Visible = true;
grid[i].AllowUserToAddRows = false;
grid[i].AllowUserToDeleteRows = false;
grid[i].AllowUserToOrderColumns = false;
grid[i].AllowUserToResizeRows = false;
grid[i].AllowUserToResizeColumns = false;
grid[i].ColumnHeadersVisible = false;
grid[i].RowHeadersVisible = false;
grid[i].Name = "grid" + c;
grid[i].Location = new System.Drawing.Point(120,5);
grid[i].Size = new System.Drawing.Size(129, 129);
grid[i].BackgroundColor = Color.Black;
grid[i].GridColor = Color.Green;
grid[i].CellBorderStyle = DataGridViewCellBorderStyle.None;
grid[i].ScrollBars = ScrollBars.None;
fill(Color.Black, Color.White);
for (j = 1; j <= 8; j++)
{
col = new DataGridViewImageColumn();
col.Width = 16;
col.Image = imglst.Images[0];
col.ImageLayout = DataGridViewImageCellLayout.Normal;
grid[i].Columns.Add(col);
grid[i].Columns[j - 1].FillWeight = 1;
}
for (k = 1; k <= 8; k++)
{
grid[i].Rows.Add();
grid[i].Rows[k - 1].Height = 16;
}
cellstl.Alignment = DataGridViewContentAlignment.MiddleCenter;
cellstl.BackColor = Color.White;
grid[i].CellMouseClick += new DataGridViewCellMouseEventHandler(this.gridmouseclick);
grid[i].CellMouseMove += new DataGridViewCellMouseEventHandler(this.gridmousemove);
grid[i].CellMouseDown += new DataGridViewCellMouseEventHandler(this.gridmousedown);
grid[i].CellMouseUp += new DataGridViewCellMouseEventHandler(this.gridmouseup);
//for (m = 1; m <= 8; m++)
//{
// for (n = 1; n <= 8; n++)
// {
// griddata[m, n] = 0;
// }
//}
epnl[i].Controls.Add(grid[i]);
cbtn[i] = new Button();
cbtn[i].Visible = true;
cbtn[i].Location = new System.Drawing.Point(1, 1);
cbtn[i].Name = "ctbn" + c;
cbtn[i].Width = 25;
cbtn[i].Height = 25;
cbtn[i].Click += new System.EventHandler(this.dropedit);
cbtn[i].BackgroundImage = Video_Project.Properties.Resources.w2;
cbtn[i].BackgroundImageLayout = ImageLayout.Stretch;
epnl[i].Controls.Add(cbtn[i]);
lbl[i] = new Label();
lbl[i].Visible = true;
lbl[i].Location = new System.Drawing.Point(3, 79);
lbl[i].Name = "lblr" + c;
lbl[i].Width = 45;
lbl[i].Height = 13;
lbl[i].Text = "Repeat:";
epnl[i].Controls.Add(lbl[i]);
lbl[i] = new Label();
lbl[i].Visible = true;
lbl[i].Location = new System.Drawing.Point(3, 106);
lbl[i].Name = "lbls" + c;
lbl[i].Width = 45;
lbl[i].Height = 13;
lbl[i].Text = "Speed:";
epnl[i].Controls.Add(lbl[i]);
lbl[i] = new Label();
lbl[i].Visible = true;
lbl[i].Location = new System.Drawing.Point(3, 145);
lbl[i].Name = "lblt" + c;
lbl[i].Width = 45;
lbl[i].Height = 13;
lbl[i].Text = "Text:";
epnl[i].Controls.Add(lbl[i]);
lbl[i] = new Label();
lbl[i].Visible = true;
lbl[i].Location = new System.Drawing.Point(3, 0);
lbl[i].AutoSize = false;
lbl[i].Width = 70;
lbl[i].Height = 70;
lbl[i].Text = c;
lbl[i].TextAlign = ContentAlignment.MiddleCenter;
epnl[i].Controls.Add(lbl[i]);
b = Convert.ToInt32(c);
b += 1;
c = Convert.ToString(b);
txt[i] = new TextBox();
txt[i].Visible = true;
txt[i].Location = new System.Drawing.Point(50, 72);
txt[i].Name = "txtr" + c;
txt[i].Width = 35;
txt[i].Height = 20;
txt[i].MaxLength = 2;
epnl[i].Controls.Add(txt[i]);
txt[i] = new TextBox();
txt[i].Visible = true;
txt[i].Location = new System.Drawing.Point(50, 103);
txt[i].Name = "txts" + c;
txt[i].Width = 35;
txt[i].Height = 20;
txt[i].MaxLength = 2;
epnl[i].Controls.Add(txt[i]);
txt[i] = new TextBox();
txt[i].Visible = true;
txt[i].Location = new System.Drawing.Point(50, 142);
txt[i].Name = "txtt" + c;
txt[i].Width = 200;
txt[i].Height = 20;
txt[i].MaxLength = 250;
epnl[i].Controls.Add(txt[i]);
x = x + 280;
}
}
我正在为另一个事件设置特定面板的可见模式
private void viewscreen_MouseDown(object sender, MouseEventArgs e)
{
int i;
if (e.Button == MouseButtons.Right)
{
for (i = 0; i <= 20; i++)
{
//string c = Convert.ToString(b);
//generate_editpanel(c);
if (b == i)
{
epnl[i].Visible = true;
}
}
}
}
我正在删除另一个事件的特定面板......
public void dropedit(object sender, EventArgs e)
{
int i;
for (i = 0; i <= 20; i++)
{
if (cbtn[i].Capture)
{
EditPanel.Controls.Remove(epnl[i]);
epnl[i].Dispose();
}
}
}
所以现在我在删除一个面板时遇到了一个间隙,我想将其余的面板向左移动并消除该间隙。任何人请帮助...如果您需要其他信息,请告诉我