如何让我的组合框不可编辑?没有将Combobox的DropDownStyle属性设置为DropDownList

编程入门 行业动态 更新时间:2024-10-11 09:27:21
本文介绍了如何让我的组合框不可编辑?没有将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

本文发布于:2023-11-06 08:47:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563221.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组合   设置为   属性   编辑   DropDownStyle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!