我想清除GroupBox的內容以使用新選項填充它,但由於我不想銷燬其中的對象(另一個文本框),因此無法使用Dispose()函數類)。 有沒有辦法在不破壞內容的情況下清空GroupBox?清除Winforms GroupBox而不破壞內容
編輯:由於其很難理解正是我想要的,這裏是我試圖做的(這是IronPython的BTW,但不應該是一個問題),如果我把這個函數的第二
def loadMethod(self, sender, e):
self.MethodParaBox.Visible = True
for i in self.MethodParaBox.Controls:
self.MethodParaBox.Controls[0].Dispose()
panel = Panel()
panel.AutoScroll = True
panel.Width = 150
panel.Height = 130
panel.Left = 25
panel.Top = 25
self.MethodParaBox.Controls.Add(panel)
for i, z in enumerate(self.parent.getParameter(self.project.SelectedItem, self.design.SelectedItem)):
if self.textBoxList[i].value.Enabled == False:
label = Label()
label.Left = 0
label.Top = 30 * i
label.Width = 80
label.Text = z
panel.Controls.Add(label)
self.textBoxList[i].option3.Left = 90
self.textBoxList[i].option3.Top = 0 + 30 * i
self.textBoxList[i].option3.Width = 40
panel.Controls.Add(self.textBoxList[i].option3)
時間,因爲文本框不再存在
環
Control.ControlCollection.Clear
Method或者
Control.ControlCollection.RemoveAt
Method或者你是什麼意思空呢?如果不刪除內容? –
我希望Groupbox爲空,但不要銷燬您想隱藏的引用內容 – Yui
? :D – Pyromancer