473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

UserControl.TextChanged

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 TextChanged;

I get a compiler error saying that TextChanged is already declared and I
have to use :
public new event EventHandler TextChanged;

With the "new" keyword added the project compiles but when I drop the
component the TextChanged event doesn't appear in the properties of the
control.

I tried to look at the source code of UserControl with the Reflector
decompiler, and in its declaration there is the TextChanged event, but you
can't access it.

The same thing appears with the Text property.

What should I do to publish both the Text and TextChanged properties?

TIA
Ciao
Formentz
Nov 15 '05 #1
4 7067
Hi,
It won't appear in the properties. This will happen if you only use
design-time code. But in your case, with the "new" then it's run-time code;
thus won't appear in the properties

--
Rami Saad
Microsoft GTSC Developer support for Middle East
"Francesco" <fr*******@togliquesto.compu-net.it> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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 TextChanged;

I get a compiler error saying that TextChanged is already declared and I
have to use :
public new event EventHandler TextChanged;

With the "new" keyword added the project compiles but when I drop the
component the TextChanged event doesn't appear in the properties of the
control.

I tried to look at the source code of UserControl with the Reflector
decompiler, and in its declaration there is the TextChanged event, but you
can't access it.

The same thing appears with the Text property.

What should I do to publish both the Text and TextChanged properties?

TIA
Ciao
Formentz

Nov 15 '05 #2
The TextChanged event indeed exists in the Control class and is related to
its Text property. I would therefore suggest you expose an event like
"TextBoxTextChanged" not to alter the standard event's semantics.
Alternatively you could use the protected OnTextChanged method to raise the
TextChanged event.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Francesco" <fr*******@togliquesto.compu-net.it> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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 TextChanged;

I get a compiler error saying that TextChanged is already declared and I
have to use :
public new event EventHandler TextChanged;

With the "new" keyword added the project compiles but when I drop the
component the TextChanged event doesn't appear in the properties of the
control.

I tried to look at the source code of UserControl with the Reflector
decompiler, and in its declaration there is the TextChanged event, but you
can't access it.

The same thing appears with the Text property.

What should I do to publish both the Text and TextChanged properties?

TIA
Ciao
Formentz


Nov 15 '05 #3
First of all thanks for the answer,

I don't understand, if you try to do this :
UserControl uc;
and then, in the code you write "uc." the code completion shows all the
methods and properties of the UserControl class, and let you select the
property or method you want to use.
But if you do so, the uc.TextChanged property doesn't appear and the same
thing occurs with uc.Text property.

So the question is : how can I show the TextChanged event in the events of
the properties window?
And to show the Text property?

Thanks

Ciao
Formentz
Hi,
It won't appear in the properties. This will happen if you only use
design-time code. But in your case, with the "new" then it's run-time code; thus won't appear in the properties

Nov 15 '05 #4
Hi Dmitry,
I would therefore suggest you expose an event like
"TextBoxTextChanged" not to alter the standard event's semantics.


it is for this reason that I want to keep the name of the event to
"TextChanged", so the control will appear as a real TextBox.
The problem is that both TextChanged and Text properties seems to be hidden
both in the designer and in code.
Please try to do :
UserControl uc;
then type "uc." to show all methods and properties of UserControl and you
will see that the two properties aren't shown in the list.

Thanks

Ciao
Formentz


Nov 15 '05 #5

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

Similar topics

3
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...
1
by: Samuel Chan | last post by:
I used the textchanged event of textbox and set the autopostback property to true. The textchanged event should fire when the content of the textbox is changed and user tab out of the textbox...
2
by: gaurav | last post by:
hi, I have a problem, How do i use TextChanged Event by clicking on Button. When i changed the text in text box and moving the focus from there then it is working but i have one calender popup...
1
by: Stan Sainte-Rose | last post by:
Hi, I have a problem with my textchanged and leave events I have a script in the leave event of my textbox and also in my textchanged. The script in my textchanged adds and displays a tabpage....
3
by: Don | last post by:
I've created a custom UserControlwithin which I have placed a Panel. I've changed the Panel's "Modifier" property to Public so that it appears in the Properties Window of the UserControl. This...
9
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
4
by: Jason Huang | last post by:
Hi, In my C# Windows form MyForm I have some TextBoxes. In these TextBoxes, we have to detect if the TextChanged event occurs, if there're changes in these TextBoxes, it will ask if we want to...
9
by: Jacek Jurkowski | last post by:
.... make COM exposed object to have both constructors COM visible not only the first one?
1
by: jeeber | last post by:
I saw this on another thread (Francesco November 15th, 2005 UserControl.TextChanged) but I didn't see how to add to the discussion, so I'm just starting a new one and hope that people find it. The...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.