如何让我的组合框不可编辑?没有将Combobox的DropDownStyle属性设置为DropDownList [英] How to make my combo box not editable? without set DropDownStyle property of Combobox to DropDownList

查看:417
本文介绍了如何让我的组合框不可编辑?没有将Combobox的DropDownStyle属性设置为DropDownList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我是C#的新手。我在窗口表单中添加了一个组合框。但我发现它在组合框中的文本在运行时是可编辑的。

但我不想将我的组合框DropDownStyle属性更改为DropDownList



有没有其他方法可以让它不可编辑?



帮助我...

Hi all,

I am a total newbie in C#. I have added a combo box in my window forms. But I found it the text in the combo box is editable during runtime.
but i do not want to change my combobox DropDownStyle property to DropDownList

is there any other way to make it un-editable?

help me...

推荐答案

我不明白你为什么要这样做,我认为这个代码是黑客...但是:
I don't understand why you want to do this, and I consider this code a hack ... but:
private void YourComboBox_KeyPress(object sender, KeyPressEventArgs e)
{
    e.Handled = true;
}


一个 ComboBox ,顾名思义,是一个组合控件。您可以直接使用 TextBox 加上 ListBox 来满足您的要求。
A ComboBox, as the name suggests, is a combined control. You might use directly a TextBox plus a ListBox to fulfill your requirements.


这篇关于如何让我的组合框不可编辑?没有将Combobox的DropDownStyle属性设置为DropDownList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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