Frage

I am trying to write a rather simple note-taking app for Elementary OS. It is my first time in C#/Mono world. I encoutered this problem.

Is it possible to take input from a Text View? I know how to do it from Entry... but how to get it from Text View?

War es hilfreich?

Lösung

As opposed to the simpler Entry class for rather short texts, TextView class is structured in a way so the data is stored in a separate data model object. That data model, a text buffer, is accessible by means of the Buffer property.

The TextBuffer.Text property of that object allows you to retrieve or modify the text shown in the TextView. Refer to the example in the TextView docs to see its exemplary use.

Andere Tipps

StreamWriter sw = new StreamWriter("Test.txt");
sw.Write(textview3.Buffer.Text); //Write textview1 text to file
//textview3.Buffer.Text = "Saved to file !"; //Notify user
sw.Close();
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top