sil*_*ilk 19
您必须访问Buffer属性,该属性表示包含GtkTextView显示的所有内容的缓冲区.
要简单地加载文本,您必须设置Text属性,如下所示:
textview1.Buffer.Text = "Some sample text that will be displayed."
Run Code Online (Sandbox Code Playgroud)
假设您添加的控件具有名称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);
Run Code Online (Sandbox Code Playgroud)
这将在第一行插入粗体文本.使用TextBuffer可以实现更多功能,查看可用的方法textview1.Buffer
.
归档时间: |
|
查看次数: |
14949 次 |
最近记录: |