1

I have made a WinForms application with a custom richtextbox control.

I am referring it as a Windows control (a dll file) in my project. In my program for the richtextbox I have written functionality inside it's textchanged event.

I want to do additional work only after the textchanged event is fired or in other ways once the text is added to the textbox. Something like I want to call a function foo() in the text_changedevent. It only calls foo and fails to process the underlying textchanged event.

Any way in C# I can make it process the internal textchanged event first, and then look into my text changed event?

think of the scenario I have written the code for mytextbox_textchanged

private void txt_code_TextChanged(object sender, EventArgs e) { //some code which will always be called whenever textchanged event occurs. } 

Now I inherit this control in my project say MyApp1. Here I have a label where I want to display the number of lines contained inside my textbox. So I would write

private void my_inherited_txt_code_TextChanged(object sender, EventArgs e) { //code to update the label with my_inherited_txt_code.lines.length } 

so my problem was, I first wanted the txt_code_TextChanged event to be called and then do the code written inside my_inherited_txt_code_TextChanged. Which was solved by writing

private void my_inherited_txt_code_TextChanged(object sender, EventArgs e) { base.OnTextChanged(e); MessageBox.Show("foo"); } 
1
  • could you post some code to demonstrate the problem? Commented Mar 13, 2009 at 10:06

2 Answers 2

1

Do you mean:

protected override void OnTextChanged(EventArgs e) { base.OnTextChanged(e); // your code here... } 
Sign up to request clarification or add additional context in comments.

Comments

0

I cant see why you shouldnt be able to call a method from the text_changed event? Do you get any errors or what happens exactly?

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.