วิธีที่จะหาควบคุมเป็นตำแหน่งจากที่ควบคุมชื่อของ

0

คำถาม

ฉันอยากจะเป็นเจควบคุมเป็นตำแหน่งจากชื่อ. นี่คือสิ่งที่ฉันต้องถึง:

private Point FindControlLocation(string ControlName, Control ParentControl)
{
    //Code...
}

ขอบคุณสำหรับอะไรช่วยด้วย!

c# controls winforms
2021-11-12 23:53:57
1

คำตอบที่ดีที่สุด

1

คุณไม่ต้องการให้พ่อแม่การควบคุมใช้รูปแบบและ recursive อกตัวเลือกจาก Controls.Find():

private Point FindControlLocation(string ControlName)
{
    Control ctl = this.Controls.Find(ControlName, true).FirstOrDefault() as Control;
    return (ctl != null) ? ctl.Location : new Point();
}
2021-11-13 01:54:51

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่