.net - Read-only (but droppable) ComboBox -


I am trying to create a Windows form combo box that is of normal color, and dropdown list But does not allow the value to actually change, as far as I can tell, it is not a duplicate because all the advice is being directed towards disabling the interactivity of the combo box.

My argument: I have a form where all the controls are read-only, and because of the nature of the application, I think that there is no need to confuse the user if there is no change in the value of the combo box. There will be no risk. I would like the user to be able to see the potential values ​​of these, in which the combo box is tied.

I have a very bad hack so far:

  Read public partial orgic classes onnikomobox: combo box {INLTI = 1; Public readline combo box () {initial group (); } Private Zero readOnlyComboBox_SelectedIndexChanged (Object Sender, EventArgs E) {If (prevIndex & lt; = 0) prevIndex = SelectedIndex; Other Selectedindex = Prendex; Basically, it ignores the duplicate "0" values ​​from the structure, and takes the first non-zero value obtained from the binding source. The immediate disadvantage is that the value can only be set once, and that it should start at bound enum 1.  

Any advice will be welcome to clean it. Thank you.

Use dropdownclosed events

  Public class ReadOnlyComboBox: ComboBox { After the Boalddrift; Int prendex; Public readline combo box () {this.SelectedIndexChanged + = new event handler (ReadOnLinkBomboxSokenIndexChanged); This.DropDownClosed + = New EventHeader (ReadOnlyComboBox_DropDownClosed); } Zero ReadOnlyComboBox_DropDownClosed (Object Sender, EventArgs e) {afterDropDown = true; } Private Zero ReadOnlyComboBox_SelectedIndexChanged (Object Sender, EventArgs e) {if (AfterDropDown) {afterDropDown = false; Selected index = prendex; } Else {prevIndex = selected index; }}}    

Comments