设置标签控件的宽度
使用Label
控件,可以在运行时从数据库设置显示文本。我试图控制控件的最大宽度,例如每行最大宽度为 100,附加字符滚动到下一行。
我通过设置和使用 CSS 进行了尝试,但没有成功:
lbl_Feedback1.Width = 50;
我认为问题在于标签的文本在应用程序运行时更新。怎么解决这个问题呢?
Using the Label
control, the display text is set during runtime from the database. I am trying to control the maximum width of the control, for example max of 100 per line with additional characters rolled over to the next line.
I tried this by setting and also using CSS with no luck:
lbl_Feedback1.Width = 50;
I believe the issue lies with the fact that the text of the label is updated during run time of the application. How to solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的标签必须设置为“display: block”才能设置宽度。
在 css 文件中设置:
或使用内联样式(来自代码隐藏):
Your label must be set to "display: block" in order to set a width.
Either set this in the css-file:
or using inline style (from code-behind):
您尝试过 max-width 属性吗?例如:最大宽度:100px;
Have your tried the
max-width
property? eg: max-width:100px;你应该能够使用
这对我有用。
You should be able to use
It worked for me.