private void newThumbNail(int docType, string fileName)
{
thmbNail[thmbNailCnt] = new GroupBox();
thmbNail[thmbNailCnt].Parent = panel1;
thmbNail[thmbNailCnt].Visible = true;
thmbNail[thmbNailCnt].Location = new Point(2, 5 + ((thmbNailCnt * 50) + 2));
thmbNail[thmbNailCnt].Size = new Size(222, 50);
picBox[thmbNailCnt] = new PictureBox();
picBox[thmbNailCnt].Parent = thmbNail[thmbNailCnt];
picBox[thmbNailCnt].Visible = true;
picBox[thmbNailCnt].Location = new Point(6, 13);
picBox[thmbNailCnt].Size = new Size(31, 31);
switch (docType)
{
case 1: picBox[thmbNailCnt].Image = wordImg;
break;
case 2: picBox[thmbNailCnt].Image = pptImg;
break;
case 3: picBox[thmbNailCnt].Image = excelImg;
break;
case 4: picBox[thmbNailCnt].Image = pdfImg;
break;
}
texBox[thmbNailCnt] = new TextBox();
texBox[thmbNailCnt].Parent = thmbNail[thmbNailCnt];
texBox[thmbNailCnt].Visible = true;
texBox[thmbNailCnt].Location = new Point(53, 24);
texBox[thmbNailCnt].Size = new Size(163, 20);
texBox[thmbNailCnt].Text = fileName;
texBox[thmbNailCnt].Enabled = false;
texBox[thmbNailCnt].BackColor = Color.Silver;
texBox[thmbNailCnt].ForeColor = Color.Black;
texBox[thmbNailCnt].DoubleClick += new System.EventHandler(changeText);
thmbNailFN[thmbNailCnt] = fileName;
data[thmbNailCnt, 0] = fileName;
data[thmbNailCnt, 1] = docType.ToString();
thmbNail[thmbNailCnt].Controls.Add(picBox[thmbNailCnt]);
thmbNail[thmbNailCnt].Controls.Add(texBox[thmbNailCnt]);
thmbNailCnt++;
}
private void changeText(object sender, EventArgs e)
{
this.Enabled = true;
}
private void newThumbNail添加一個包含圖片框和文本框作爲其元素的組框。我爲文本框自定義了一個雙擊事件,不幸的是它沒有執行。爲什麼?自定義文本框的雙擊
「this.Enabled」是否有假?如果父容器('this')被禁用,它將不會收到任何事件。 .Net沒有控制數組,所以我對這個代碼示例所看到的有點困惑。 – LarsTech 2012-03-21 01:34:51