Click here to Skip to main content
16,006,845 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: combobox last item to first item [modified] Pin
Jay Royall22-Apr-09 6:21
Jay Royall22-Apr-09 6:21 
GeneralRe: combobox last item to first item Pin
johnny196322-Apr-09 10:16
johnny196322-Apr-09 10:16 
GeneralRe: combobox last item to first item Pin
johnny196322-Apr-09 10:32
johnny196322-Apr-09 10:32 
GeneralRe: combobox last item to first item [modified] Pin
Johan Hakkesteegt22-Apr-09 21:01
Johan Hakkesteegt22-Apr-09 21:01 
GeneralRe: combobox last item to first item Pin
johnny196322-Apr-09 21:37
johnny196322-Apr-09 21:37 
GeneralRe: combobox last item to first item Pin
Johan Hakkesteegt22-Apr-09 21:39
Johan Hakkesteegt22-Apr-09 21:39 
GeneralRe: combobox last item to first item Pin
johnny196322-Apr-09 23:32
johnny196322-Apr-09 23:32 
AnswerRe: combobox last item to first item [modified] Pin
Alan N22-Apr-09 12:18
Alan N22-Apr-09 12:18 
Hi,
How is this happening then?

Setting the Text property of the combobox implicity changes the SelectedIndex property. Therefore your code must set SelectedIndex to 0.

ComboBox1.Text = ComboBox1.Items(0).ToString()

But what happens next? The default mouse wheel handling then increments the SelectedIndex from 0 to 1 to give the observed effect of always getting the second item selected.

The solution must be to disable the default handling for the one special case of wrapping the index from bottom to top and you’ll have to do this via an override of the OnMouseWheel method.

In c# I'd do this

protected override void OnMouseWheel(MouseEventArgs e) {
  if (specialcase) {
    // Explicitly set selected index
    SelectedIndex = 0;
    // and don't call the base class method
  } else {
    // default action, let the base class handle it
    base.OnMouseWheel(e);
  }
}

Let me know if this works, as it's a bit of a guess on my part.

Alan.

modified on Wednesday, April 22, 2009 9:33 PM

GeneralRe: combobox last item to first item Pin
johnny196322-Apr-09 20:15
johnny196322-Apr-09 20:15 
GeneralRe: combobox last item to first item Pin
Alan N22-Apr-09 22:50
Alan N22-Apr-09 22:50 
GeneralRe: combobox last item to first item Pin
johnny196322-Apr-09 23:36
johnny196322-Apr-09 23:36 
QuestionMacro for retrieving word template password Pin
Jaison Peter22-Apr-09 1:05
Jaison Peter22-Apr-09 1:05 
AnswerRe: Macro for retrieving word template password Pin
Dave Kreskowiak22-Apr-09 1:54
mveDave Kreskowiak22-Apr-09 1:54 
GeneralRe: Macro for retrieving word template password Pin
Jaison Peter22-Apr-09 3:19
Jaison Peter22-Apr-09 3:19 
GeneralRe: Macro for retrieving word template password Pin
Eddy Vluggen22-Apr-09 4:11
professionalEddy Vluggen22-Apr-09 4:11 
GeneralRe: Macro for retrieving word template password Pin
Jaison Peter22-Apr-09 4:38
Jaison Peter22-Apr-09 4:38 
GeneralRe: Macro for retrieving word template password Pin
Eddy Vluggen22-Apr-09 4:52
professionalEddy Vluggen22-Apr-09 4:52 
GeneralRe: Macro for retrieving word template password Pin
Jaison Peter22-Apr-09 5:03
Jaison Peter22-Apr-09 5:03 
GeneralRe: Macro for retrieving word template password Pin
Jaison Peter22-Apr-09 5:05
Jaison Peter22-Apr-09 5:05 
GeneralRe: Macro for retrieving word template password Pin
Eddy Vluggen22-Apr-09 6:21
professionalEddy Vluggen22-Apr-09 6:21 
Questioncall a procedure in a textbox Pin
Qendro21-Apr-09 23:40
Qendro21-Apr-09 23:40 
AnswerRe: call a procedure in a textbox Pin
Henry Minute22-Apr-09 0:00
Henry Minute22-Apr-09 0:00 
GeneralRe: call a procedure in a textbox Pin
Qendro22-Apr-09 0:11
Qendro22-Apr-09 0:11 
QuestionDownload ActiveX Pin
p_196021-Apr-09 22:55
p_196021-Apr-09 22:55 
AnswerRe: Download ActiveX Pin
Christian Graus22-Apr-09 10:55
protectorChristian Graus22-Apr-09 10:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.