I can't understand how to load text into a GtkTexView, how is it done?
You have to access the Buffer property that represents the buffer holding all the content that is shown by GtkTextView.
To simply load a text, you must set the Text property, like that:
textview1.Buffer.Text = "Some sample text that will be displayed."
Assuming the control you added has the name textview1.
If you want some more control on the apperance of the text, you have to use tags to mark the text. For example:
var tag = new TextTag (null);
this.textview1.Buffer.TagTable.Add (tag);
tag.Weight = Pango.Weight.Bold;
var iter = this.textview1.Buffer.GetIterAtLine (0);
this.textview1.Buffer.InsertWithTags (ref iter, "Bold text\n", tag);
This will insert a bold text in first line. A lot more is possible using the TextBuffer, look on the methods available on textview1.Buffer
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With