如何使组合框中的WinForms只读 [英] How to make Combobox in winforms readonly

查看:152
本文介绍了如何使组合框中的WinForms只读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不希望用户能够改变在下拉列表中显示的值。我一直在使用已启用=假,但它变灰的文字,所以不是很可读。我希望它表现得像一个文本框只读=真正的,其中文本正常显示,但用户无法对其进行编辑。

I do not want the user to be able to change the value displayed in the combobox. I have been using Enabled = false but it grays out the text, so it is not very readable. I want it to behave like a textbox with ReadOnly = true, where the text is displayed normally, but the user can't edit it.

时有完成这个的一种方式?

Is there is a way of accomplishing this?

推荐答案

这篇文章的组合框与 - 只读行为提出了一个有趣的解决方案:

The article ComboBox-with-read-only-behavior suggests an interesting solution:

创建既是一个只读的文本框,并在同一个地方的组合框。当你想只读模式,显示文本框,当你希望它是编辑,显示组合框。

Create both a readonly textbox and a combobox in the same place. When you want readonly mode, display the textbox, when you want it to be editable, display the combobox.

这篇关于如何使组合框中的WinForms只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆