Gui.cs: How do you get TextView text changed to work

Created on 21 Jan 2021  路  3Comments  路  Source: migueldeicaza/gui.cs

Hello!
I want to add syntax Highlighting to my TextView and i made a prototype to detect if text has changed. I tried using editor.TextChanged but that didn' work. Do you guys have another idea how to accomplish my goal? Anyways,
Here is the code i tried it with

editor.TextChanged += () =>
{
      System.Windows.Forms.MessageBox.Show("Text Changed");
};

This does not work.
I would appreciate help, thank you.

UPDATE: Pressing CTRL will bring the MessageBox to show and it pastes using System.Windows.Forms; in the TextView then

Most helpful comment

I think it would be better to ask about possible ways to pull off syntax highlighting instead.

All 3 comments

TextChangedonly fires if the Textproperty is changed and not when you are typing, because you don't want to save the changes. But there must be a Changedevent just to notify the user that they can get the changes with get method Text.

If you want to do syntax highlighting you might want to inherit from TextView and override ReDraw?

I think it would be better to ask about possible ways to pull off syntax highlighting instead.

Was this page helpful?
0 / 5 - 0 ratings