 |
|
ขอคำแนะนำครับ เรื่อง ส่งค่าจาก Form ไป User Control ไม่ได้ครับ |
|
 |
|
|
 |
 |
|
แนะว่าให้เพิ่ม property ใน User Control จะเหมาะกว่า และเป็นรูปแบบที่ใช้กันทั่วไปมากกว่า(ไม่รู้จะใช้ศัพท์ไหน)
ประมาณนี้ครับ
Code (VB.NET)
Public Class UserControl1
<Category("Tor Property"), _
Description("SubID")> _
Public Property SubID() As String
Get
Return lbl_supID.Text
End Get
Set(value As String)
lbl_supID.Text = value
End Set
End Property
<Category("Tor Property"), _
Description("SubName")> _
Public Property SubName() As String
Get
Return txt_supName.Text
End Get
Set(value As String)
txt_supName.Text = value
End Set
End Property
End Class
พอลงในฟอร์ม เราก็แก้ในหน้า ดีไซน์ ได้ด้วยแบบนี้

ถ้าไม่อยากให้แก้ได้ก็แค่เอา
Code (VB.NET)
<Category("Tor Property"), _
Description("SubID")> _
กับ
Code (VB.NET)
<Category("Tor Property"), _
Description("SubName")> _
ออก
แต่ก็สามารถเรียกใช้ในโค้ดได้แบบนี้

ซึ่งส่วนใหญ่การเขียน User Control ก็มักจะใช้วิธีนี้กัน
|
 |
 |
 |
 |
Date :
2019-02-20 18:12:11 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Verygood
|
 |
 |
 |
 |
Date :
2019-02-20 18:23:59 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|