带有超链接的PropertyGrid提示
本文关键字:PropertyGrid 提示 超链接 | 更新日期: 2023-09-27 18:10:55
是否可以添加一个可点击的超链接到属性网格提示?
我有以下在我的类(被分配到属性网格作为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;
在属性网格中查看时,链接不可点击。什么好主意吗?
查看MSDN参考,PropertyGrid
使用两个Label
s,一个用于标题,一个用于描述:
http://referencesource.microsoft.com/System.Windows.Forms/winforms/管理/系统/winforms/PropertyGridInternal/DocComment.cs a0b78590be82b950
Label
不支持超链接。您可以做的是在描述标签上放置一个RichTextBox
,并让它显示文本。例如
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;
};