vb.net怎么在两个自定义控件之间进行传值
vb.net如何在两个自定义控件之间进行传值
自定义了两个控件UserControl1和UserControl2,请问,如何将UserControl1中的一个属性值传递给UserControl2,UserContro2如何接收?请高手帮忙解答
------解决方案--------------------
UserControl1 定义属性
UserControl2 读取
------解决方案--------------------
自定义控件是类
类具有属性
类创建对象后,可以访问对象的属性或字段,例如
自定义了两个控件UserControl1和UserControl2,请问,如何将UserControl1中的一个属性值传递给UserControl2,UserContro2如何接收?请高手帮忙解答
------解决方案--------------------
UserControl1 定义属性
UserControl2 读取
------解决方案--------------------
自定义控件是类
类具有属性
类创建对象后,可以访问对象的属性或字段,例如
Public Class UserControl1
private v as Double
Public Property Value as Double
Get
return v
End Get
Set
v = value
End Set
End Property
End Class
Public Class UserControl2
private v as Double
Public Property Value as Double
Get
return v
End Get
Set
v = value
End Set
End Property
End Class
'调用的地方
Dim u1 as new UserControl1
Dim u2 as new UserControl2
u1.Value = 100
u2.Value = u1.Value