C# 自訂義搜尋控件


使用這個方法就可以更方便的搜尋需要的Controls

// 遞迴尋找控制項的方法
private Control FindControlByName(Control parentControl, string name)
{
    if (parentControl.Name == name)
    {
        return parentControl;
    }

    foreach (Control childControl in parentControl.Controls)
    {
        Control targetControl = FindControlByName(childControl, name);
        if (targetControl != null)
        {
            return targetControl;
        }
    }

    return null;
}
#C# #Winform







你可能感興趣的文章

筆記:淺談 JavaScript 頭號難題 this:絕對不完整,但保證好懂

筆記:淺談 JavaScript 頭號難題 this:絕對不完整,但保證好懂

展開運算子(Spread Operator) & 其餘運算子(Rest Operator)

展開運算子(Spread Operator) & 其餘運算子(Rest Operator)

再戰原型鏈

再戰原型鏈






留言討論





2
2
2