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







你可能感興趣的文章

Letter Combinations of a Phone Number

Letter Combinations of a Phone Number

我遇過的最難的 Cookie 問題

我遇過的最難的 Cookie 問題

Git cherry pick 實戰: 作業分支混到 master commit,但又不想洗掉自己作業的 commit 要怎麼辦?

Git cherry pick 實戰: 作業分支混到 master commit,但又不想洗掉自己作業的 commit 要怎麼辦?






留言討論