使用Usercontrol中的get和set属性设置文本框宽度 [英] textbox width using get and set property in Usercontrol
本文介绍了使用Usercontrol中的get和set属性设置文本框宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1.我在Usercontrol中有一个文本框
< uc1:MultipleSelectionCtrl ID < span class =code-keyword> = ContractingOfficeLocationCtrl runat = 服务器 可见 = false / >
2.具有文本框属性的控件页单元
公共 Pr operty TextBoxWidth() As 单位
获取
返回 txtSelection.Width
结束 获取
设置( ByVal 值作为单位)
txtSelection.Width = value
结束 设置
< span class =code-keyword>结束 物业
3.现在我想从Codebehind给出文本框的宽度百分比
帮助我.......
解决方案
首先,我建议你阅读:演练:创建Web自定义控制 [ ^ ]
其次,要使用百分比值更改宽度
控件,您需要计算它。例如,当您传递50
作为输入参数(pw
)时,
< pre lang =vb> textbox1.Width = textbox1.Width * pw / 100
' 我们需要将pw除以100,因为50%= 0.5
1.I'm having a textbox in Usercontrol
<uc1:MultipleSelectionCtrl ID="ContractingOfficeLocationCtrl" runat="server" Visible="false" />
2.Control pages having the Property of textbox a Unit
Public Property TextBoxWidth() As Unit
Get
Return txtSelection.Width
End Get
Set(ByVal value As Unit)
txtSelection.Width = value
End Set
End Property
3.Now i want to give the width of textbox in percentage from Codebehind
Help me.......
解决方案
First of all, i would recommend you to read this: Walkthrough: Creating a Web Custom Control[^]
Secondly, to changeWidth
of control using percentage value, you need to calculate it. For example, when you pass50
as a input parameter (pw
),
textbox1.Width = textbox1.Width * pw / 100 'we need to divide pw per 100, because 50% = 0.5
这篇关于使用Usercontrol中的get和set属性设置文本框宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文