How to lock combobox for typing
开发者_如何学运维I use DevExpress 2.4
and I have a combobox which is bound to a row in a propertygrid control. I want to disable this combobox for editing it content by keyboard and be able only to choose the value by clicking with the mouse. I read on the internet just to change the DropDownStyle
property to DropDownList
, instead of DropDown
but when I go to the combobox in properties I don't have property DropDownList
and only DropDownItemHeight
and DropDownRows
... So how to disable typing in this combobox?
Open property editor for this GridControl
and open repository, now in options of this ComboBox
go down to TextEditStyle
and choose DisableTextEditor
as option.
Just do this: this.comboBoxType.DropDownStyle = ComboBoxStyle.DropDownList;
How about using the LookupEdit control?
the point about setting the DropDownStyle they have told you is right for standard .NET Framework windows forms DropDowsLists, the DevExpress one you are using is a different control which offers a much richer API and feature set.
I have used the XtraEditors very much in the past and I was always able to get what I needed, can't remember now the exact property name but surely there is a property to do what you need now, not exposed to the main control, try to check the properties of the current editor in your combo box.
In VB.NET, we do as :
ComboBoxEdit1.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor
I hope there will be similar for C#.NET.
Grid Control Repository Item has its own properties. You could view it by
Run Designer -> Repository -> In-place Editor Repository
Select the item you wish to edit the property. Explore those properties and you would love the manipulation of the properties.
BTW, just change the TextEditStyle
property to DisableTextEditor
.
Enjoy!
Example : Two Mehtods Disable Editing or Lock ComboBox
Through code Simple Code:
DropDownListName.DropDownStyle = ComboBoxStyle.DropDownList;
Using Design Properties of Visual Studio:
Set (DropDownList : DropDownList)
I hope this well Help you.
C# This locks Combobox manual input and displays only comboboxlist items
this.yourcomboBoxname.DropDownStyle = ComboBoxStyle.DropDownList;
精彩评论