是否可以在属性网格提示中添加可点击的超链接?
我的课程中有以下内容(已将属性网格指定为SelectedObject
):
[Browsable(true),
ReadOnly(false),
Category("7. InnoDB"),
DefaultValue(1),
Description("Defines what happens after InnoDB transaction commit, for more details view https://mariadb.com/kb/en/mariadb/xtradbinnodb-server-system-variables/#innodb_flush_log_at_trx_commit")]
public int innodb_flush_log_at_trx_commit { get; set; } = 1;
在属性网格中查看时,该链接无法点击。有什么想法吗?
答案 0 :(得分:3)
查看MSDN参考,PropertyGrid
使用两个Label
,一个用于标题,一个用于描述:
Label
不支持超链接。您可以做的是在描述标签上放置RichTextBox
,然后让它显示文本。 E.g。
PropertyGrid pg = new PropertyGrid() { Dock = DockStyle.Fill };
Control c = pg.Controls[0]; // internal DocComment control
Label l1 = (Label) c.Controls[1];
RichTextBox tb = new RichTextBox { Multiline = true, WordWrap = true, ReadOnly = true, BorderStyle = BorderStyle.None };
c.Controls.Add(tb);
c.Controls.SetChildIndex(tb, 0);
l1.TextChanged += delegate {
tb.Text = l1.Text;
};
l1.SizeChanged += delegate {
tb.Size = l1.Size;
};
l1.LocationChanged += delegate {
tb.Location = l1.Location;
};