我无法理解如何将文本加载到GtkTexView中,它是如何完成的?
发布于 2010-12-01 03:17:19
您必须访问Buffer属性,该属性表示保存GtkTextView显示的所有内容的缓冲区。
要简单地加载文本,必须设置text属性,如下所示:
textview1.Buffer.Text = "Some sample text that will be displayed."假设您添加的控件的名称为textview1。
如果你想对文本的外观有更多的控制,你必须使用标签来标记文本。例如:
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);这将在第一行插入一个粗体文本。使用TextBuffer可以实现更多功能,请查看textview1.Buffer上提供的方法。
https://stackoverflow.com/questions/4292286
复制相似问题