DevExpress中标签控件中如何select文本?
How to select text in the label control in DevExpress?
我可以在 DevExpress 的标签控件中 select 文本吗?
我需要这样的东西:
编辑
private void AddLayoutItem(LayoutControlGroup group, string name, string description)
{
group.AllowHtmlStringInCaption = true;
LabelControl label = new LabelControl
{
Name = Guid.NewGuid().ToString(),
Text = description,
Font = new Font("Tahoma", 11),
Padding = new Padding(25, 0, 0, 0),
AutoSizeMode = LabelAutoSizeMode.Vertical,
AllowDrop = true,
BorderStyle = 0,
IsAccessible = true
};
AddLayoutItem(group, name, label);
}
LabelControl
不支持显示文本的 selection。
但是,这可以通过 TextEdit
实现,您可以使它看起来像标签,但用户可以 select 文本。将其 BorderStyle 属性 设置为 NoBorder 并将 ReadOnly 设置为 true。
您的代码将如下所示:
private void AddLayoutItem(LayoutControlGroup group, string name, string description)
{
group.AllowHtmlStringInCaption = true;
var edit = new TextEdit
{
Name = Guid.NewGuid().ToString(),
Text = description,
Font = new Font("Tahoma", 11)
};
edit.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
edit.Properties.ReadOnly = true;
AddLayoutItem(group, name, edit);
}
我可以在 DevExpress 的标签控件中 select 文本吗?
我需要这样的东西:
编辑
private void AddLayoutItem(LayoutControlGroup group, string name, string description)
{
group.AllowHtmlStringInCaption = true;
LabelControl label = new LabelControl
{
Name = Guid.NewGuid().ToString(),
Text = description,
Font = new Font("Tahoma", 11),
Padding = new Padding(25, 0, 0, 0),
AutoSizeMode = LabelAutoSizeMode.Vertical,
AllowDrop = true,
BorderStyle = 0,
IsAccessible = true
};
AddLayoutItem(group, name, label);
}
LabelControl
不支持显示文本的 selection。
但是,这可以通过 TextEdit
实现,您可以使它看起来像标签,但用户可以 select 文本。将其 BorderStyle 属性 设置为 NoBorder 并将 ReadOnly 设置为 true。
您的代码将如下所示:
private void AddLayoutItem(LayoutControlGroup group, string name, string description)
{
group.AllowHtmlStringInCaption = true;
var edit = new TextEdit
{
Name = Guid.NewGuid().ToString(),
Text = description,
Font = new Font("Tahoma", 11)
};
edit.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
edit.Properties.ReadOnly = true;
AddLayoutItem(group, name, edit);
}