using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraRichEdit;
namespace Lskj.MyControl
{
public partial class LabelRichEdit : UserControl
{
///
/// Label填充值
///
protected int PaddingLeft = 7;
///
/// 只读颜色
///
protected Color ReadOnlyLabelForceColor = Color.FromArgb(160, 160, 160);
///
/// 必填颜色
///
protected Color RequiredLabelForceColor = Color.Blue;
///
/// Label 默认颜色
///
protected Color DefaultLabelForceColor = Color.Black;
///
/// 富文本控件
///
public RichEditControl TextEdit { get { return richEditControl1; } }
public LabelRichEdit()
{
InitializeComponent();
}
///
/// 说明:设置控件显示文本
/// 创建人:龚宇超
/// 创建日期:2017-08-07
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// 显示Lebel文本
public string LabelText
{
get
{
return this.lblText.Text;
}
set
{
this.lblText.Text = value;
this.plLeft.Width = this.lblText.Width + PaddingLeft;
}
}
///
/// 说明:设置控件值
/// 创建人:龚宇超
/// 创建日期:2017-08-07
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
public string EditText
{
get
{
return this.richEditControl1.RtfText;
}
set
{
if (value.StartsWith(@"{\rtf"))
this.richEditControl1.RtfText = value;
else
this.richEditControl1.Text = value;
}
}
///
/// 是否只读
///
/// The color of the read only label.
public bool ReadOnly
{
get
{
return !this.TextEdit.Enabled;
}
set
{
this.TextEdit.Enabled = !value;
this.lblText.ForeColor = value ? ReadOnlyLabelForceColor : Required ? RequiredLabelForceColor : DefaultLabelForceColor;
}
}
///
/// 必填文本颜色
///
/// The color of the required label.
public bool Required
{
get
{
return this.Required;
}
set
{
Required = value;
if (value)
{
this.lblText.ForeColor = RequiredLabelForceColor;
}
}
}
}
}