在下面的代碼中,我該如何將變量類型傳遞給嵌套的foreach語句? 是的GetControls遞歸函數返回一個列表控件(哇!)動態分類的foreach變量
getControls(String type, Control donde)
var tipos = new List<Type>() { typeof(Button), typeof(KryptonTextBox) };
foreach (Type t in tipos)
{
List<Control> controls = getControls(t.ToString(), this);
foreach (***** c in controls)
{
c.StateCommon.Back.Color1 = Color.White;
}
}
恩......「Button」沒有「StateCommon」成員。您將無法在返回的按鈕上運行該代碼。 – 2009-10-23 20:54:03
@Joel你不知道Button的實際類型是什麼,所以很難說明確的。 – technophile 2009-10-23 20:56:07
我稍後再嘗試... – Luiscencio 2009-10-23 20:58:56