Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi..
i have defined a method to get the richtextbox as a very first control of tabcontol..
but i need to work on its textchanged event..
is it possible to define an event manually? if yes then how it can be used.??

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 9-Jul-12 13:34pm    
The exact type of RichTextBox, please. There is more than one.
--SA

1 solution

C#
RichTextBox rtb = new RichTextBox();
rtb.TextChanged += new EventHandler(rtb_TextChanged);




C#
private void rtb_TextChanged(object sender, EventArgs e)
{
  // process the text changed event 
}


EDIT

Ok, without knowing what kind of richtextbox i'll try to answer.
Assume you have created object of richtextbox from code behind and its name is rtb

if you type rtb and dot you can find the methods properties and events of it, find TextChanged and hit enter.
ones you done that press + mark and = key and press tab key twice. it will generate event for you.

hope this helps.
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 9-Jul-12 13:35pm    
How do you know which RichTextBox? OP did not specify its type (there are more than one), and you support this. We should avoid answering those ambiguous questions.
--SA
DamithSL 10-Jul-12 2:43am    
Way of adding event to a control is common in .net so answer was helpful that's why OP accept it. agreed with you but guessing and answering is sometimes better than clarify by a comment.
Sergey Alexandrovich Kryukov 11-Jul-12 15:22pm    
Well, I guess it depends on personal preferences to some extent... well, as you did not miss anyway, I'll up-vote it this time, only by 4, not by 5. I'll explain where is the imperfection: rtb_TextChanged violates (good) Microsoft naming conventions. Yes, auto-generated code does violate Microsoft naming conventions, and this is even good -- it tells you that you did not retouch this code yet and reminds you to rename the member to something semantic when you get to it. Also, I would advise anonymous handlers in some 99% cases (and not using Designer on event; the Designer writes bad handler code).
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900