|
-
Dec 11th, 2006, 11:29 AM
#1
Thread Starter
Fanatic Member
prevent object event from firing
Hi guys,
I have a combobox that i want to (when my program loads) set to a default selectedindex value. Is there any way i can do this without the selectedIndexChanged event from firing. The reason i need this is because i have code in the the event but i dont want it to run unless the user changes the index manually (not while its done at runtime in the code)? If this isn't possible then is there another way around my problem?
Thanks in advance for any help
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
Dec 11th, 2006, 11:35 AM
#2
Re: prevent object event from firing
You could simply have a boolean value. On the index changed routine check first for it. If it's true then exit sub and it wont execute the code.
-
Dec 11th, 2006, 11:47 AM
#3
Thread Starter
Fanatic Member
Re: prevent object event from firing
Bingo! Thats what i was looking for.....thanks for that....i'll try it out and let you know whether it works.
Thanks again.
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
Dec 11th, 2006, 12:38 PM
#4
Re: prevent object event from firing
There's a much easy way...
Use AddHandler to associate any procedure to an event and RemoveHandler to disassociate anytime in your program at your will.
Pradeep
-
Dec 12th, 2006, 04:14 AM
#5
Thread Starter
Fanatic Member
Re: prevent object event from firing
Its only when i create the combobox at run-time that i dont want it to fire because i am going to default the index, so would it be worth using RemoveHandler.....i haven't got round to trying out either method yet so i'd appreciate some more input if anybody has any.
Thanks again for all the help so far!
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
Dec 12th, 2006, 02:13 PM
#6
Re: prevent object event from firing
It can be used for both controls created at design time or runtime.
It's easier than you think. Just try it once ad see for yourself.
Pradeep
-
Dec 12th, 2006, 08:52 PM
#7
Re: prevent object event from firing
There's an even easier way. Don't handle the SelectedIndexChanged event. The SelectedIndexChanged event is raised whenever the SelectedIndex property changes. If what you actually want to detect is when the user makes a selection then the appropriate event to handle is SelectionChangeCommitted.
-
Dec 13th, 2006, 03:38 AM
#8
Thread Starter
Fanatic Member
Re: prevent object event from firing
Is that event supported with the .net compact framework?
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
Dec 13th, 2006, 06:59 AM
#9
Re: prevent object event from firing
-
Dec 13th, 2006, 07:05 AM
#10
Thread Starter
Fanatic Member
Re: prevent object event from firing
Ok kool....i know i didn't specify i was using cf but i didn't think it would be necessary....so apologies to anyone who gave advice that i cant use!
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
Dec 13th, 2006, 07:21 AM
#11
Re: prevent object event from firing
http://msdn2.microsoft.com/en-us/library/719dt662.aspx
I wouldn't mind a full CF. The modern handhelds are powerfull enough and their optimized hardware easily beats a 'Pentium 133 MHz' & '256 MB'.
-
Dec 13th, 2006, 07:48 AM
#12
Re: prevent object event from firing
Always specify your version and always specify that you're using the CF unless you post in the dedicated Mobile forum.
-
Dec 13th, 2006, 08:14 AM
#13
Member
Re: prevent object event from firing
Dim bFormloadInProgress As Boolean in the form that has the control.
When you enter form load set bFormloadInProgress = True and when you are about to exit the form load event. set bFormloadInProgress = False
In selectedIndexChanged event use the foll code at the beginning
If bFormloadInProgress = True Then
Exit Sub
End If
Hope this helps.
Sugan.
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
|