vb.net 如何制作具有只读外观的 DropDownList
我正在使用 vb.net 和 vs2008 开发桌面应用程序。
我有一个 DropDownList,当信息被锁定时,我不希望它与使用交互。
但如果我禁用它,它就会变灰并且文本不容易阅读。
有没有办法使单选按钮像只读文本框一样?
我希望 DropDownList 的文本看起来是黑色的,并且本身不可单击。
上面显示了一个禁用的 DropDownList,其中包含灰色文本和只读文本框
I am developing desktop application using vb.net and vs2008.
I have a DropDownList that I don't want it interact with use when the info is locked.
But if I disable it, it is greyed out and the text is not easy to read.
Is there any way to make radiobutton like readonly textbox?
I want text of the DropDownList looks black and itself is not clickable.
The above shows a disabled DropDownList with greyed out text and a readonly textbox
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
试试这个:
Enable="false"
将其放在
标记中。Try this:
Enable="false"
Place it within your
<asp:DropDownList>
tag.我最近遇到了类似的问题。我的解决方案是删除 DropDownList 中除所选值之外的所有其他值。这将使文本保持黑色而不是灰色。用户将能够看到现有值并单击它,但无法更改它。
希望这有帮助。
I recently encountered a similar issue. My solution was to remove all other values of the DropDownList except the one that is selected. This will keep the text as black as opposed to grey. Users will be able see the existing value and click it but will not be able to change it.
Hope this helps.
不,您不能在桌面应用程序中使用 CSS。当您通过设置Disabled=true禁用下拉列表时;或Enabled=false(无论是什么情况),您还可以更改字体属性以使其更易于阅读。您可以设置其他属性,例如 Border、BorderStyle 等。
No, you can't use CSS in a desktop app. When you disable the dropdownlist by setting Disabled=true; or Enabled=false (whatever the case is), you can also change the Font properties to make it easier to read. You can set other properties such as Border, BorderStyle, etc, etc.
保持控件启用。在 GOTFOCUS 事件中,使用 SENDKEYS 将 {tab} 发送到表单。用户将无法更改它!顺便说一句,适用于用户可以关注的所有控件。
Keep the control enabled. In the GOTFOCUS event, use SENDKEYS to send a {tab} to the form. the user will not be able to change it! By the way, workt for ALL controls, that a user can focus.
试试这个
Try this