After selecting an item in the combobox, this item remains highlighted in blue and can be scrolled with the mouse wheel. It interferes. Is it possible to do so that after selecting an item in the combobBox by clicking on the free space, the selection in blue disappears and the mouse wheel does not change the selection of the item? or so that scrolling with the wheel is possible only when the comboBox list is expanded.
|
2 answers
You can do this: create an event handler to change the selected element and at the end of the event method transfer the focus to another control or form, for example
Form1.Focus(); UPD The fact is that the Focus () method does not select, but transfers focus. The focus is the current element, it can only be one at a time.
- An error occurs: Error 1 For a non-static field, method or property "System.Windows.Forms.Control.Focus ()", an object reference F: \ Documents and Settings \ Passenger №9 \ My Documents \ Visual Studio 2010 \ Projects \ Copy is required Copy 3.0 \ 3.0 \ Form1.cs 108 13 3.0 - Vezd
- 2So you do not call the method of the class, and the object. - Modus
- I realized that you can transfer to lable and then everything is fine. But at the beginning of debugging (Debug), for some reason, Form1 is loaded with one dedicated control, although I have label3.Focus () written at the end of the Form1_Load method ; - Vezd
|
You can add to the event handler at the very end
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { ....... this.comboBox1.MouseWheel += this.comboBox1_MouseWheel; } Add a procedure to disable scroll
private void comboBox1_MouseWheel(object sender, MouseEventArgs e) { ((HandledMouseEventArgs)e).Handled=true; } If you think well, you can think of a procedure that will switch true / false as needed
|