|
-
Jan 22nd, 2008, 08:53 PM
#1
Thread Starter
Addicted Member
[2005] SelectedIndexChanged Problem
Hi
I have a combobox "cboPreviousPreparationEntries". Now I have a sub
Private Sub cboPreviousPreparationEntries_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboPreviousPreparationEntries.SelectedIndexChanged
So this runs when the selected value of combo box is changed. Now for some reason in the code i need to put
cboPreviousPreparationEntries.SelectedIndex = 2
But at that time it calls the sub automatically as the index is changed, but I DO NOT WANT it to call that sub mentioned on top. Is that possible?
I hope i made myself clear.
-
Jan 22nd, 2008, 09:02 PM
#2
Re: [2005] SelectedIndexChanged Problem
Handle the SelectionChangeCommitted event instead, which is raised only when the user makes a change through the UI.
-
Jan 22nd, 2008, 09:04 PM
#3
Lively Member
Re: [2005] SelectedIndexChanged Problem
What I'd do is just make a boolean (I made it public but you can send it through the function parameter list if you want):
Code:
Public ManualChange as Boolean = False
Code:
ManualChange = True
cboPreviousPreparationEntries.SelectedIndex = 2
Code:
Private Sub cboPreviousPreparationEntries_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboPreviousPreparationEntries.SelectedIndexChanged
If ManualChange = True Then
ManualChange = False
'Rest of code
End If
But I guess you could optimize it.
Wow that was easy. *slaps himself* I need to write that down.
"He who asks a question is a fool for five minutes; he who does not ask a question remains a fool forever."
-
Jan 23rd, 2008, 08:54 AM
#4
Frenzied Member
Re: [2005] SelectedIndexChanged Problem
 Originally Posted by jmcilhinney
Handle the SelectionChangeCommitted event instead, which is raised only when the user makes a change through the UI.
Can you elaborate on this? SelectionChangeCommitted does not appear to be an event of a combo box.
-
Jan 23rd, 2008, 07:17 PM
#5
Re: [2005] SelectedIndexChanged Problem
 Originally Posted by nbrege
Can you elaborate on this? SelectionChangeCommitted does not appear to be an event of a combo box.
You are kidding aren't you? Where exactly have you looked to come to that conclusion? The screen shot below shows just four ways you could have found it and they are not the only ways either.
Last edited by jmcilhinney; Feb 9th, 2008 at 04:13 AM.
-
Jan 24th, 2008, 08:02 AM
#6
Frenzied Member
Re: [2005] SelectedIndexChanged Problem
My mistake. I was looking at a ToolStripComboBox. I assumed it would have the same events as a standard ComboBox control.
-
Jan 24th, 2008, 05:19 PM
#7
Re: [2005] SelectedIndexChanged Problem
 Originally Posted by nbrege
My mistake. I was looking at a ToolStripComboBox. I assumed it would have the same events as a standard ComboBox control.
A ToolStripComboBox is not a ComboBox. It is a ToolStripControlHost designed to host a ComboBox. It has a ComboBox property that refers to the ComboBox it's hosting. That ComboBox has a SelectionChangedCommitted event. Alternatively you could inherit the ToolStripComboBox class and add a SelectionChangeCommitted event.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|