473,320 Members | 1,829 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,320 software developers and data experts.

UserControl.TextChanged .NET C#

1
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 original problem was creating a user control and trying to use existing event types like "TextChanged", if you were creating a control that was similar to a text box, for example.

The problem was that the developers at Microsoft decided that this event shouldn't be seen, so even if you add your own event handler to your user control, the event doesn't show up in the event properties window in the designer, which is kind of a nuisance.

The solution is to use an attribute mark-up to override the attributes that were set to hide the event in the first place. So your code would look like this:

Expand|Select|Wrap|Line Numbers
  1. [EditorBrowsable(EditorBrowsableState.Always), Browsable(true)]
  2. public new event EventHandler TextChanged;
  3.  
You can find information on the attributes in the help files, kind of interesting for adding properties to your control that you want to see in the designer.

The "new" is needed because you can't override the base TextChanged (even though it does nothing! Very strange), so you basically replace it completely.

Hope this helps,

Jay
Mar 20 '07 #1
1 3977
kenobewan
4,871 Expert 4TB
Welcome to the site. Thanks for sharing your solution to the problem.
Mar 20 '07 #2

Sign in to post your reply or Sign up for a free account.

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...
4
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...
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?
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.