Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ON TextChanged event

Status
Not open for further replies.

kurie

Programmer
Jun 4, 2008
170
ZA
The following piece of code is run thrugh But not executed when i used on textchanged event, but it's executed when i put it under the on lostfocus event of a textbox.
Public Sub txtLocation_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtLocation.TextChanged
picEdit.Enabled = False
btnFirst.Enabled = False
btnPrevious.Enabled = False
btnNext.Enabled = False
btnLast.Enabled = False
end sub
can anyone please help me on why this isnt working, im still to vb.net
 
1) In what way is it not working?
2) What is txtLocation?


-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Try placing a breakpoint at the beginning of your sub, next to the Public.... Then run your code. Then enter text into your txtLocation textbox (IF it is a textbox). Your code should stop on the sub and you can step thru the code to see what's happening.

I ran a test program with code similiar to what you posted and it works just fine.
 
My code runs perfectly even if i add break points, i can view the text, i can display the text to a message box.
The new text is not written to the text box nor can the set visible property working. everything cant seem to work, i have tried using Application.DoEvents() but still doesnt work.
Suprisingly though,the other events like lost focus are working with the same code, its just the textxhanged.

<hate computers>
 
sorry Sorwen
txtLocation is a textbox and im writing text to it from another form.
The textchanged event is trigirred but the effects are not displayed on the form.
 
So each one of these:
picEdit.Enabled = False
btnFirst.Enabled = False
btnPrevious.Enabled = False
btnNext.Enabled = False
btnLast.Enabled = False
None of them are grayed out and each can still be clicked on. I wanted to make sure it wasn't a case of one or two working and the others were not. Now at some point after typing I assume you would want to enable them again? Where did you put the code that sets them to .Enabled = True?

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
How are you referencing text, controls, etc. from your second form????? Again, I added a second form, added a couple of controls and from my Form1 textbox changed event was able to affect the second form.

I'm not sure if textchanged would be the best place to alter another form, as it gets called EVERYTIME you change the text, meaning you type 1 character and your other form gets updated.
 
Hie all
This is how im referencing my text
frm1.textbox1 = "something", this im doing in form2.
then i would like the textbox1_onchange event to run the code to enable buttons and the likes and also importanatly to write the text, "something" to frm1.textbox1.

and Sorwen none of the code or btns are disabled.
 
So the text is being changed programatically via txtLocation.text = "Something"?

if it is try
txtLocation.text = "Something"
RaiseEvent txtLocation.TextChanged

does the event fire then?
 
Hie guys,
this is what i have done so far as a work around,
i put the code in on lostfocus event, and just after updating the textbox i set focus to another button and everything is working fine.
But i still dont know why the ontextchanged event doesnt work.
Sillsod i tried your solution but no joy, the event fires but and the code is executed but i dont see the results on the form. like the text is not changing, the buttons are not enabled.
Thank you guys for your help. but i wish i could find a solution to this problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top