473,503 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forcing TextChanged event on setting Control.Text

TextChanged is only called when the user modifes a control's text, not
if the program does.

How can I make it be called when the program modifies the text?

Zytan

Feb 1 '07 #1
8 3445
Just call the method.

T

Zytan wrote:
>TextChanged is only called when the user modifes a control's text, not
if the program does.

How can I make it be called when the program modifies the text?

Zytan
Feb 1 '07 #2
Tomb,

Thanks for the reply.

I can't just call TextBox1.TextChanged(), since it's an event. I need
to use RaiseEvent to do that, which can only be used on declared
events.

I could call TextBox1_TextChanged(), the function that the event
invokes. But, what do I pass it as arguments?

Even if I CAN pass the proper arguments, I'd have to make this call in
*every place* that I manually change the text. <sigh>

There has got to be a better way that just invokes the event when the
text is changed, no matter WHO changes it.

Zytan

Feb 1 '07 #3
On Jan 31, 9:07 pm, "Zytan" <zytanlith...@yahoo.comwrote:
TextChanged is only called when the user modifes a control's text, not
if the program does.

How can I make it be called when the program modifies the text?

Zytan
TextChanged is only called when the user modifes a control's text, not
if the program does.
Are you sure? The following works fine for me...

Private Sub TextBox1_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Me.TextBox1.BackColor = Color.Red
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Me.TextBox1.Text = "hello"
End Sub

As soon as the button is clicked, the _TextChanged Event Fires,
turning it red.

Thanks,

Seth Rowe

Feb 1 '07 #4
On Feb 1, 1:46 pm, "Zytan" <zytanlith...@yahoo.comwrote:
Tomb,

Thanks for the reply.

I can't just call TextBox1.TextChanged(), since it's an event. I need
to use RaiseEvent to do that, which can only be used on declared
events.

I could call TextBox1_TextChanged(), the function that the event
invokes. But, what do I pass it as arguments?

Even if I CAN pass the proper arguments, I'd have to make this call in
*every place* that I manually change the text. <sigh>

There has got to be a better way that just invokes the event when the
text is changed, no matter WHO changes it.

Zytan
I could call TextBox1_TextChanged(), the function that the event
invokes. But, what do I pass it as arguments?
TextBox1_TextChanged(me.TextBox1, EventArgs.Empty)

Thanks,

Seth Rowe

Feb 1 '07 #5
Zytan wrote:
TextChanged is only called when the user modifes a control's text, not
if the program does.

How can I make it be called when the program modifies the text?
I don't see this behavior. From what I know, the TextChanged event
will be called whenever you change the text, regardless if by your
code or from the UI...

Maybe you need to describe your exact problem.

Regards,

Branco.

Feb 1 '07 #6
Are you sure? The following works fine for me...
>
...

As soon as the button is clicked, the _TextChanged Event Fires,
turning it red.
Whoa! You are absolutely right! Thanks for the information, Seth!

What I am doing in response to the text changed event is determining
if the file that is typed into it exists or not (yes, I know, there
could be issues with slowing down the GUI with networks, etc., but
this is just a quick 'n dirty application, so it's ok for now).

So, obviously my code is being run, but the code that is being run
isn't working. Which is strange, since I am initializing the text box
to contain text of an existing file. If I change one character in it,
and then undo that change, (i.e. causing the USER to create the exact
text that the program does), my code will work! Hmm... must be
something to do with the Form1_Load() event... I'll mess around and
post back in a bit...

Zytan
Feb 1 '07 #7
I could call TextBox1_TextChanged(), the function that the event
invokes. But, what do I pass it as arguments?

TextBox1_TextChanged(me.TextBox1, EventArgs.Empty)
Thanks again, Seth. You're a great help.

Zytan

Feb 1 '07 #8
Maybe you need to describe your exact problem.

Branco, I would have included more information at the start, but I
didn't think it was relevant.

I simply goofed... The response to the TextChanged() event was to see
if the filename typed in existed or not, and respond with a visible
reaction. It appears something else was overriding that initial
programmatic reaction (in Form1_Load), so I didn't see it. It was
working all along... <sigh>

You guys have been a great help. Thanks again!

Zytan
Feb 1 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2915
by: Fabrício de Novaes Kucinskis | last post by:
Hi all, I have a combobox control, in wich I put an autocomplete code. This code is in the TextChanged event, but when this event fires, the Text property isn't updated yet. For example, if...
4
7073
by: Francesco | last post by:
Hi all, I am trying to make a UserControl with a TextBox in it. I have to publish the TextChanged event of the inner TextBox, but I have some trouble. If I declare : public event EventHandler...
3
4610
by: Kurt Schroeder | last post by:
I'm setting focus depenting upon which field has changed value. I'm doing this with the following: Page.RegisterStartupScript("SetFocus", "<script language=""Jscript"" >...
3
6467
by: Fabrício de Novaes Kucinskis | last post by:
Hi all, I have a combobox control, in wich I put an autocomplete code. This code is in the TextChanged event, but when this event fires, the Text property isn't updated yet. For example, if...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7348
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7006
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5592
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3166
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
397
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.