패널 안에 많은 레이블과 텍스트 상자가있는 Windows 응용 프로그램에 System.Windows.Forms.Panel 컨트롤이 있습니다. Panel.Enabled = false 명령을 호출하면 모든 텍스트 상자와 레이블이 회색으로 변하고 편집 할 수 없게되어 원하는 효과가 나타납니다. 패널을 사용할 수 없을 때 연한 회색을 과부하하는 방법이 있습니까?System.Windows.Forms.Panel.Enabled = false 색 오버로드?
솔루션 사용 :
사용할 때 사용할 색상 overiden 질수 있기 때문에 다음은 났을 Panel.Enabled = 거짓 ;.보다는 패널에만 텍스트 상자와 라벨을 사용하지 않도록 설정하는 데 사용
//Loop through the Member info Panel and find all the group boxes
foreach (Control cItem in Panel.Controls)
{
//A group box is found
if (cItem is GroupBox)
{
//Loop through all the group box components
foreach (Control cSubItem in cItem.Controls)
{
//If its a label of text box disable it
if (cSubItem is TextBox || cSubItem is Label)
{
cSubItem.Enabled = false;
}
}
}
}
나는 반복 할 논리를 찾고있었습니다. 패널은 솔기가 없어 자식 콜렉션이 없으므로 작동 할 폼 수준에서 반복 할 것이지만 메인 부모 노드가 무엇인지 알아낼 필요가 있습니다. –