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







你可能感興趣的文章

MTR04_0714

MTR04_0714

有趣的 WEB 特效與技巧分享

有趣的 WEB 特效與技巧分享

[筆記] React 隨手記 (環境建置、常用功能說明)

[筆記] React 隨手記 (環境建置、常用功能說明)






留言討論