|
-
Jul 22nd, 2004, 09:26 AM
#1
Thread Starter
Frenzied Member
? Which Control Events to use?
Esteemed Forum Participants and Lurkers:
Trying to track down all of the possible combinations of control event actions and INTERactions seems to be the hardest part of GUI programming. I found that true in LabWindows CVI, and it seems to be true for VB.NET as well.
I have a text edit box "File", and I want to clear out a 'default selector' radio button if the text in the text box is edited.
All I need to know is which is/are the best text box event/events to use in my handler -
I do NOT want the handler process to run when the Form opens or closes. I do not want it to run when I load the default into the text box during initialization. I just want it to run only on completion of any edit on the text.
Is there a GOOD comprehensive list of control event definitions available?
Thank you for any and all suggestions, comments, and assistance.
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Jul 22nd, 2004, 09:45 AM
#2
Frenzied Member
two ways come to mind. one is use the 'textChanged' event but i THINK that fires when you load your default text. it really depends when you load that default. if you do it after the form has loaded or if you have it set before. Another way is to use a constant for the default and use the Leave() event. compare the Text property to the constant.
-
Jul 22nd, 2004, 09:47 AM
#3
just put code in the change event that if the text = the default text to not change the option button, otherwise change it
-
Jul 22nd, 2004, 09:48 AM
#4
Frenzied Member
here's alink to msdn.com that shows you all the members.
http://msdn.microsoft.com/library/de...mberstopic.asp
-
Jul 22nd, 2004, 10:57 AM
#5
Thread Starter
Frenzied Member
Thanks for the assistance ...
The table from the MS site was somewhat helpful, but of course it only indicates SOME of the cases where an event is fired - not a comprehensive listing of EVERYTHING UNDER THE SUN that fires an event.
There is definitely no substitute for UNDERSTANDING all of the intricacies of events, but that is a never ending quest.
The problem is actually more complex than I indicated - one textbox has several defaults available through radio buttons, and I don't want to have to go through a compare list every time the box is edited. A nice 'edit termination' event would be so much cleaner.
I tried "MouseEnter", but it is totally erratic. In some cases it fires when the box is entered, but in other cases, it doesn't fire when the box is entered, but when the mouse enters some OTHER box (yuk). As I recall, Validate gets fired when the form is loaded ...
This is rediculous.
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Jul 22nd, 2004, 11:39 AM
#6
Sleep mode
Use Validating event . It fires after Leave and before LostFocus events .
-
Jul 22nd, 2004, 12:05 PM
#7
Frenzied Member
you really wouldn't want the MouseEnter event. there no control over the time of events. that's only useful for poping up help topics or tips and such (from my experience) As far as another box reacting to the event of another...that's odd. lol
Pirate's right too, that event occur's between those two time frames. I always forget about that event cause I never use it 
And, i'm pretty sure that's all the events you're gonna find for that given control. unless of course you create your own control inherited from the textBox class.
-
Jul 23rd, 2004, 03:16 AM
#8
Hyperactive Member
I have faced similar problem in my app.
I noted that when textchanged was fired by initialize components, a Textbox1.UNDO doesn't change the textbox.text, so it doesn't fired a new text changed event. Storing your actual text and using UNDO and static variables to flag when your textchanged event procedure is going to do a change, probably you can detect what you need. I solved my problem in similar way.
If you don't need to use input from clipboard, in your textbox, and so if any valid input must be due to a keypressed, than you can detect valid textchanged with a flag previously setted in keydown event. Anyway, good job!
Live long and prosper (Mr. Spock)
-
Jul 23rd, 2004, 06:59 AM
#9
Thread Starter
Frenzied Member
Alextyx -
Thanks for your comments - and thanks to everyone else as well. Your suggestion about setting a flag is of course a 'state machine', and they can be useful, especially if it only involves 2 or 3 states. They can also be a nuisance.
I finally ended up with a couple of different approaches - one text box uses 'Validating', 'Keyup', and 'Keypress' (checks for <Enter>). One just uses 'Keyup' and assumes an edit and clears out the default selector radio buttons on every keystroke. I'm still working on a third set of textboxes which deal with the relationship between a file path box and a file name box.
The bottom line is that it sure would be nice to have a reliable "end of edit" event. I guess I'll keep working on that - in my 'spare' time (lol).
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Jul 23rd, 2004, 07:01 AM
#10
PowerPoster
Hi,
Unless I'm missing something, surely the LostFocus Event is ideal.
Another idea, whichever event you choose, is to set a boolean to false in the form load event, set it to true when a default button is pressed or a textchanged event is fired, and set it to false when the chosen event is fired. Then make the first line of the chosen event
VB Code:
If boolean=false then exit sub
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
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
|