// *********************************************************************** // Assembly : HZH_Controls // Created : 08-08-2019 // // *********************************************************************** // // Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com // // // Blog: https://www.cnblogs.com/bfyx // GitHub:https://github.com/kwwwvagaa/NetWinformControl // gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git // // If you use this code, please keep this note. // *********************************************************************** 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; namespace HZH_Controls.Controls { /// /// Class UCListItemExt. /// Implements the /// /// [ToolboxItem(false)] public partial class UCListItemExt : UserControl { /// /// Gets or sets the title. /// /// The title. [Description("标题"), Category("自定义")] public string Title { get { return label1.Text; } set { label1.Text = value; } } /// /// Gets or sets the title2. /// /// The title2. [Description("副标题"), Category("自定义")] public string Title2 { get { return label3.Text; } set { label3.Text = value; label3.Visible = !string.IsNullOrEmpty(value); var g = label3.CreateGraphics(); var size = g.MeasureString(value, label3.Font); label3.Width = (int)size.Width + 10; } } /// /// Gets or sets the title font. /// /// The title font. [Description("标题字体"), Category("自定义")] public Font TitleFont { get { return label1.Font; } set { label1.Font = value; } } /// /// Gets or sets the title2 font. /// /// The title2 font. [Description("副标题字体"), Category("自定义")] public Font Title2Font { get { return label3.Font; } set { label3.Font = value; } } /// /// Gets or sets the color of the item back. /// /// The color of the item back. [Description("背景色"), Category("自定义")] public Color ItemBackColor { get { return this.BackColor; } set { this.BackColor = value; } } /// /// Gets or sets the color of the item fore. /// /// The color of the item fore. [Description("标题文本色"), Category("自定义")] public Color ItemForeColor { get { return label1.ForeColor; } set { label1.ForeColor = value; } } /// /// Gets or sets the item fore color2. /// /// The item fore color2. [Description("副标题文本色"), Category("自定义")] public Color ItemForeColor2 { get { return label3.ForeColor; } set { label3.ForeColor = value; } } /// /// Gets or sets a value indicating whether [show more BTN]. /// /// true if [show more BTN]; otherwise, false. [Description("是否显示右侧更多箭头"), Category("自定义")] public bool ShowMoreBtn { get { return label2.Visible; } set { label2.Visible = value; ; } } /// /// Occurs when [item click]. /// [Description("项选中事件"), Category("自定义")] public event EventHandler ItemClick; /// /// 数据源 /// /// The data source. public ListEntity DataSource { get; private set; } [Description("分割线颜色"), Category("自定义")] public Color SplitColor { get { return this.splitLine_H1.BackColor; } set { this.splitLine_H1.BackColor = value; } } /// /// Initializes a new instance of the class. /// public UCListItemExt() { InitializeComponent(); SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); this.UpdateStyles(); } /// /// Handles the MouseDown event of the item control. /// /// The source of the event. /// The instance containing the event data. private void item_MouseDown(object sender, MouseEventArgs e) { if (ItemClick != null) { ItemClick(this, e); } } #region 设置数据 /// /// 功能描述:设置数据 /// 作  者:HZH /// 创建日期:2019-02-27 11:52:52 /// 任务编号:POS /// /// data public void SetData(ListEntity data) { this.Title = data.Title; this.Title2 = data.Title2; this.ShowMoreBtn = data.ShowMoreBtn; DataSource = data; } #endregion } }