如何使组合框中的WinForms只读组合、框中、WinForms

由网友(辣逼,小心!)分享简介:我不希望用户能够改变在下拉列表中显示的值。我一直在使用已启用=假,但它变灰的文字,所以不是很可读。我希望它表现得像一个文本框只读=真正的,其中文本正常显示,但用户无法对其进行编辑。I do not want the user to be able to change the value displayed in th...

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

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.

阅读全文

相关推荐

最新文章