동적으로 컨트롤을 추가하는 GroupBox가 있습니다. 내가 추가 한 컨트롤은 두 가지 유형 DevExpress.XtraEditors.TextEdit
및 Windows.Forms.Label
의있는 나는이 올바르게 TextEdit
컨트롤 아닌 Label
컨트롤을 제거하고WinForm에서 동적으로 추가 된 컨트롤 제거
foreach (Control control in salesBox.Controls)
{
control.Dispose();
salesBox.Controls.Remove(control);
}
다음 사용하여 이러한 컨트롤을 제거하려합니다. 루프는 Label
컨트롤을 반복하지 않습니다.
이 작동 것() 메서드 – Nabegh
맞아, ControlCollection은 IEnumerable이 아닙니다. 해결할 답변을 수정했습니다. System.Linq 네임 스페이스가 필요합니다 –