Readonly ComboBox in WinForms

久未见 提交于 2019-11-28 13:16:16

Set DropDownStyle to "DropDownList"

Set the ComboBox.DropDownStyle property to ComboBoxStyle.DropDownList.

Another simple way to go about it.

private void combobox1_KeyPress(object sender, KeyPressEventArgs e)
{
    e.Handled = true;
}
David Max

Use code similar to the following to set the allowed options and only those options.

comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox1.Items.AddRange(new object[] {
    "One",
    "Two",
    "Three",
    "Four"});

Try using a DropDownListbox

My requirement : once user giving an input through combo-box they can not change the value before submit it. They can read only that value.

As per my requirement i do the following things.

1) Get input from user through combo-box.
2) Copy the value of combo-box to a text-box(which is read only and invisible).
3) False the visibility of combo-box.
4) True the visibility of read only text-box.

Do this with events.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!