官网

http://www.hzhcontrols.com

前提

入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。

GitHub:https://github.com/kwwwvagaa/NetWinformControl

码云:https://gitee.com/kwwwvagaa/net_winform_custom_control.git

如果觉得写的还行,请点个 star 支持一下吧

欢迎前来交流探讨: 企鹅群568015492 

麻烦博客下方点个【推荐】,谢谢

NuGet

Install-Package HZH_Controls

目录

https://www.cnblogs.com/bfyx/p/11364884.html

用处及效果

   List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "ID", HeadText = "编号", Width = , WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Name", HeadText = "姓名", Width = , WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Age", HeadText = "年龄", Width = , WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Birthday", HeadText = "生日", Width = , WidthType = SizeType.Absolute, Format = (a) => { return ((DateTime)a).ToString("yyyy-MM-dd"); } });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Sex", HeadText = "性别", Width = , WidthType = SizeType.Absolute, Format = (a) => { return ((int)a) == ? "女" : "男"; } });
this.ucComboxGrid1.GridColumns = lstCulumns;
List<object> lstSourceGrid = new List<object>();
for (int i = ; i < ; i++)
{
TestModel model = new TestModel()
{
ID = i.ToString(),
Age = * i,
Name = "姓名——" + i,
Birthday = DateTime.Now.AddYears(-),
Sex = i %
};
lstSourceGrid.Add(model);
}
this.ucComboxGrid1.GridDataSource = lstSourceGrid;

准备工作

此控件继承自UCCombox,并且需要表格控件UCDataGridView,如果不了解请移步查看

(三十五)c#Winform自定义控件-下拉框

(三十二)c#Winform自定义控件-表格

如果你想显示树形结构,请移步查看

(四十七)c#Winform自定义控件-树表格(treeGrid)

开始

我们首先需要一个弹出的面板,那么我们先添加一个用户控件UCComboxGridPanel,在这个用户控件上添加一个文本框进行搜索,添加一个表格展示数据

一些属性

  [Description("项点击事件"), Category("自定义")]
public event DataGridViewEventHandler ItemClick;
private Type m_rowType = typeof(UCDataGridViewRow); public Type RowType
{
get { return m_rowType; }
set
{
m_rowType = value;
this.ucDataGridView1.RowType = m_rowType;
}
} private List<DataGridViewColumnEntity> m_columns = null; public List<DataGridViewColumnEntity> Columns
{
get { return m_columns; }
set
{
m_columns = value;
this.ucDataGridView1.Columns = value;
}
}
private List<object> m_dataSource = null; public List<object> DataSource
{
get { return m_dataSource; }
set { m_dataSource = value; }
} private string strLastSearchText = string.Empty;
UCPagerControl m_page = new UCPagerControl();

一些事件,处理数据绑定

  void ucDataGridView1_ItemClick(object sender, DataGridViewEventArgs e)
{
if (ItemClick != null)
{
ItemClick((sender as IDataGridViewRow).DataSource, null);
}
} void txtInput_TextChanged(object sender, EventArgs e)
{
timer1.Enabled = false;
timer1.Enabled = true;
} private void UCComboxGridPanel_Load(object sender, EventArgs e)
{
m_page.DataSource = m_dataSource;
this.ucDataGridView1.DataSource = m_page.GetCurrentSource();
} private void timer1_Tick(object sender, EventArgs e)
{
if (strLastSearchText == txtSearch.InputText)
{
timer1.Enabled = false;
}
else
{
strLastSearchText = txtSearch.InputText;
Search(txtSearch.InputText);
}
} private void Search(string strText)
{
m_page.StartIndex = ;
if (!string.IsNullOrEmpty(strText))
{
strText = strText.ToLower();
List<object> lst = m_dataSource.FindAll(p => m_columns.Any(c => (c.Format == null ? (p.GetType().GetProperty(c.DataField).GetValue(p, null).ToStringExt()) : c.Format(p.GetType().GetProperty(c.DataField).GetValue(p, null))).ToLower().Contains(strText)));
m_page.DataSource = lst;
}
else
{
m_page.DataSource = m_dataSource;
}
m_page.Reload();
}

完整代码

 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.ComboBox
{
[ToolboxItem(false)]
public partial class UCComboxGridPanel : UserControl
{
[Description("项点击事件"), Category("自定义")]
public event DataGridViewEventHandler ItemClick;
private Type m_rowType = typeof(UCDataGridViewRow); public Type RowType
{
get { return m_rowType; }
set
{
m_rowType = value;
this.ucDataGridView1.RowType = m_rowType;
}
} private List<DataGridViewColumnEntity> m_columns = null; public List<DataGridViewColumnEntity> Columns
{
get { return m_columns; }
set
{
m_columns = value;
this.ucDataGridView1.Columns = value;
}
}
private List<object> m_dataSource = null; public List<object> DataSource
{
get { return m_dataSource; }
set { m_dataSource = value; }
} private string strLastSearchText = string.Empty;
UCPagerControl m_page = new UCPagerControl(); public UCComboxGridPanel()
{
InitializeComponent();
this.ucDataGridView1.Page = m_page;
this.ucDataGridView1.IsAutoHeight = false;
this.txtSearch.txtInput.TextChanged += txtInput_TextChanged;
this.ucDataGridView1.ItemClick += ucDataGridView1_ItemClick;
} void ucDataGridView1_ItemClick(object sender, DataGridViewEventArgs e)
{
if (ItemClick != null)
{
ItemClick((sender as IDataGridViewRow).DataSource, null);
}
} void txtInput_TextChanged(object sender, EventArgs e)
{
timer1.Enabled = false;
timer1.Enabled = true;
} private void UCComboxGridPanel_Load(object sender, EventArgs e)
{
m_page.DataSource = m_dataSource;
this.ucDataGridView1.DataSource = m_page.GetCurrentSource();
} private void timer1_Tick(object sender, EventArgs e)
{
if (strLastSearchText == txtSearch.InputText)
{
timer1.Enabled = false;
}
else
{
strLastSearchText = txtSearch.InputText;
Search(txtSearch.InputText);
}
} private void Search(string strText)
{
m_page.StartIndex = ;
if (!string.IsNullOrEmpty(strText))
{
strText = strText.ToLower();
List<object> lst = m_dataSource.FindAll(p => m_columns.Any(c => (c.Format == null ? (p.GetType().GetProperty(c.DataField).GetValue(p, null).ToStringExt()) : c.Format(p.GetType().GetProperty(c.DataField).GetValue(p, null))).ToLower().Contains(strText)));
m_page.DataSource = lst;
}
else
{
m_page.DataSource = m_dataSource;
}
m_page.Reload();
}
}
}
 namespace HZH_Controls.Controls.ComboBox
{
partial class UCComboxGridPanel
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region 组件设计器生成的代码 /// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.ucControlBase1 = new HZH_Controls.Controls.UCControlBase();
this.ucDataGridView1 = new HZH_Controls.Controls.UCDataGridView();
this.txtSearch = new HZH_Controls.Controls.UCTextBoxEx();
this.ucSplitLine_V2 = new HZH_Controls.Controls.UCSplitLine_V();
this.ucSplitLine_V1 = new HZH_Controls.Controls.UCSplitLine_V();
this.ucSplitLine_H2 = new HZH_Controls.Controls.UCSplitLine_H();
this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
this.panel1.SuspendLayout();
this.ucControlBase1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.ucControlBase1);
this.panel1.Controls.Add(this.panel2);
this.panel1.Controls.Add(this.txtSearch);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(, );
this.panel1.Name = "panel1";
this.panel1.Padding = new System.Windows.Forms.Padding();
this.panel1.Size = new System.Drawing.Size(, );
this.panel1.TabIndex = ;
//
// panel2
//
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
this.panel2.Location = new System.Drawing.Point(, );
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(, );
this.panel2.TabIndex = ;
//
// timer1
//
this.timer1.Interval = ;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// ucControlBase1
//
this.ucControlBase1.ConerRadius = ;
this.ucControlBase1.Controls.Add(this.ucDataGridView1);
this.ucControlBase1.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucControlBase1.FillColor = System.Drawing.Color.Transparent;
this.ucControlBase1.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucControlBase1.IsRadius = false;
this.ucControlBase1.IsShowRect = true;
this.ucControlBase1.Location = new System.Drawing.Point(, );
this.ucControlBase1.Margin = new System.Windows.Forms.Padding(, , , );
this.ucControlBase1.Name = "ucControlBase1";
this.ucControlBase1.Padding = new System.Windows.Forms.Padding();
this.ucControlBase1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.ucControlBase1.RectWidth = ;
this.ucControlBase1.Size = new System.Drawing.Size(, );
this.ucControlBase1.TabIndex = ;
this.ucControlBase1.TabStop = false;
//
// ucDataGridView1
//
this.ucDataGridView1.BackColor = System.Drawing.Color.White;
this.ucDataGridView1.Columns = null;
this.ucDataGridView1.DataSource = null;
this.ucDataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucDataGridView1.HeadFont = new System.Drawing.Font("微软雅黑", 12F);
this.ucDataGridView1.HeadHeight = ;
this.ucDataGridView1.HeadPadingLeft = ;
this.ucDataGridView1.HeadTextColor = System.Drawing.Color.Black;
this.ucDataGridView1.IsAutoHeight = false;
this.ucDataGridView1.IsShowCheckBox = false;
this.ucDataGridView1.IsShowHead = true;
this.ucDataGridView1.Location = new System.Drawing.Point(, );
this.ucDataGridView1.Name = "ucDataGridView1";
this.ucDataGridView1.Page = null;
this.ucDataGridView1.RowHeight = ;
this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDataGridView1.Size = new System.Drawing.Size(, );
this.ucDataGridView1.TabIndex = ;
this.ucDataGridView1.TabStop = false;
//
// txtSearch
//
this.txtSearch.BackColor = System.Drawing.Color.Transparent;
this.txtSearch.ConerRadius = ;
this.txtSearch.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtSearch.DecLength = ;
this.txtSearch.Dock = System.Windows.Forms.DockStyle.Top;
this.txtSearch.FillColor = System.Drawing.Color.Empty;
this.txtSearch.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.txtSearch.InputText = "";
this.txtSearch.InputType = HZH_Controls.TextInputType.NotControl;
this.txtSearch.IsFocusColor = true;
this.txtSearch.IsRadius = true;
this.txtSearch.IsShowClearBtn = true;
this.txtSearch.IsShowKeyboard = false;
this.txtSearch.IsShowRect = true;
this.txtSearch.IsShowSearchBtn = false;
this.txtSearch.KeyBoardType = HZH_Controls.Controls.KeyBoardType.UCKeyBorderAll_EN;
this.txtSearch.Location = new System.Drawing.Point(, );
this.txtSearch.Margin = new System.Windows.Forms.Padding(, , , );
this.txtSearch.MaxValue = new decimal(new int[] {
,
,
,
});
this.txtSearch.MinValue = new decimal(new int[] {
,
,
,
-});
this.txtSearch.Name = "txtSearch";
this.txtSearch.Padding = new System.Windows.Forms.Padding();
this.txtSearch.PromptColor = System.Drawing.Color.Gray;
this.txtSearch.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.txtSearch.PromptText = "输入内容模糊搜索";
this.txtSearch.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.txtSearch.RectWidth = ;
this.txtSearch.RegexPattern = "";
this.txtSearch.Size = new System.Drawing.Size(, );
this.txtSearch.TabIndex = ;
//
// ucSplitLine_V2
//
this.ucSplitLine_V2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.ucSplitLine_V2.Dock = System.Windows.Forms.DockStyle.Right;
this.ucSplitLine_V2.Location = new System.Drawing.Point(, );
this.ucSplitLine_V2.Name = "ucSplitLine_V2";
this.ucSplitLine_V2.Size = new System.Drawing.Size(, );
this.ucSplitLine_V2.TabIndex = ;
this.ucSplitLine_V2.TabStop = false;
//
// ucSplitLine_V1
//
this.ucSplitLine_V1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.ucSplitLine_V1.Dock = System.Windows.Forms.DockStyle.Left;
this.ucSplitLine_V1.Location = new System.Drawing.Point(, );
this.ucSplitLine_V1.Name = "ucSplitLine_V1";
this.ucSplitLine_V1.Size = new System.Drawing.Size(, );
this.ucSplitLine_V1.TabIndex = ;
this.ucSplitLine_V1.TabStop = false;
//
// ucSplitLine_H2
//
this.ucSplitLine_H2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.ucSplitLine_H2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.ucSplitLine_H2.Location = new System.Drawing.Point(, );
this.ucSplitLine_H2.Name = "ucSplitLine_H2";
this.ucSplitLine_H2.Size = new System.Drawing.Size(, );
this.ucSplitLine_H2.TabIndex = ;
this.ucSplitLine_H2.TabStop = false;
//
// ucSplitLine_H1
//
this.ucSplitLine_H1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.ucSplitLine_H1.Dock = System.Windows.Forms.DockStyle.Top;
this.ucSplitLine_H1.Location = new System.Drawing.Point(, );
this.ucSplitLine_H1.Name = "ucSplitLine_H1";
this.ucSplitLine_H1.Size = new System.Drawing.Size(, );
this.ucSplitLine_H1.TabIndex = ;
this.ucSplitLine_H1.TabStop = false;
//
// UCComboxGridPanel
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.panel1);
this.Controls.Add(this.ucSplitLine_V2);
this.Controls.Add(this.ucSplitLine_V1);
this.Controls.Add(this.ucSplitLine_H2);
this.Controls.Add(this.ucSplitLine_H1);
this.Name = "UCComboxGridPanel";
this.Size = new System.Drawing.Size(, );
this.Load += new System.EventHandler(this.UCComboxGridPanel_Load);
this.panel1.ResumeLayout(false);
this.ucControlBase1.ResumeLayout(false);
this.ResumeLayout(false); } #endregion private UCSplitLine_H ucSplitLine_H1;
private UCSplitLine_H ucSplitLine_H2;
private UCSplitLine_V ucSplitLine_V1;
private UCSplitLine_V ucSplitLine_V2;
private System.Windows.Forms.Panel panel1;
private UCControlBase ucControlBase1;
private UCDataGridView ucDataGridView1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Timer timer1;
private UCTextBoxEx txtSearch;
}
}

以上,弹出面板完成,下面就是下拉控件了

添加一个用户控件UCComboxGrid,继承UCCombox

一些属性

  private Type m_rowType = typeof(UCDataGridViewRow);

         [Description("表格行类型"), Category("自定义")]
public Type GridRowType
{
get { return m_rowType; }
set
{
m_rowType = value;
}
}
int intWidth = ; private List<DataGridViewColumnEntity> m_columns = null; [Description("表格列"), Category("自定义")]
public List<DataGridViewColumnEntity> GridColumns
{
get { return m_columns; }
set
{
m_columns = value;
if (value != null)
intWidth = value.Sum(p => p.WidthType == SizeType.Absolute ? p.Width : (p.Width < ? : p.Width));
}
}
private List<object> m_dataSource = null; [Description("表格数据源"), Category("自定义")]
public List<object> GridDataSource
{
get { return m_dataSource; }
set { m_dataSource = value; }
} private string m_textField; [Description("显示值字段名称"), Category("自定义")]
public string TextField
{
get { return m_textField; }
set
{
m_textField = value;
SetText();
}
}
[Obsolete("不再可用的属性")]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
private new ComboBoxStyle BoxStyle
{
get;
set;
}
private object selectSource = null; [Description("选中的数据源"), Category("自定义")]
public object SelectSource
{
get { return selectSource; }
set
{
selectSource = value;
SetText();
if (SelectedChangedEvent != null)
{
SelectedChangedEvent(value, null);
}
}
} [Description("选中数据源改变事件"), Category("自定义")]
public new event EventHandler SelectedChangedEvent;

重写点击事件来处理弹出

  protected override void click_MouseDown(object sender, MouseEventArgs e)
{
if (m_columns == null || m_columns.Count <= )
return;
if (m_ucPanel == null)
{
var p = this.Parent.PointToScreen(this.Location);
int intScreenHeight = Screen.PrimaryScreen.Bounds.Height;
int intHeight = Math.Max(p.Y, intScreenHeight - p.Y - this.Height);
intHeight -= ;
m_ucPanel = new UCComboxGridPanel();
m_ucPanel.ItemClick += m_ucPanel_ItemClick;
m_ucPanel.Height = intHeight;
m_ucPanel.Width = intWidth;
m_ucPanel.Columns = m_columns;
m_ucPanel.RowType = m_rowType;
if (m_dataSource != null && m_dataSource.Count > )
{
int _intHeight = Math.Min( + m_dataSource.Count * , m_ucPanel.Height);
m_ucPanel.Height = _intHeight;
}
}
m_ucPanel.DataSource = m_dataSource;
if (_frmAnchor == null || _frmAnchor.IsDisposed || _frmAnchor.Visible == false)
{
_frmAnchor = new Forms.FrmAnchor(this, m_ucPanel);
_frmAnchor.Show(this.FindForm());
} } void m_ucPanel_ItemClick(object sender, DataGridViewEventArgs e)
{
_frmAnchor.Hide();
SelectSource = sender;
} private void SetText()
{
if (!string.IsNullOrEmpty(m_textField) && selectSource != null)
{
var pro = selectSource.GetType().GetProperty(m_textField);
if (pro != null)
{
TextValue = pro.GetValue(selectSource, null).ToStringExt();
}
}
}

完整代码

 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 HZH_Controls.Controls; namespace HZH_Controls.Controls.ComboBox
{
public partial class UCComboxGrid : UCCombox
{ private Type m_rowType = typeof(UCDataGridViewRow); [Description("表格行类型"), Category("自定义")]
public Type GridRowType
{
get { return m_rowType; }
set
{
m_rowType = value;
}
}
int intWidth = ; private List<DataGridViewColumnEntity> m_columns = null; [Description("表格列"), Category("自定义")]
public List<DataGridViewColumnEntity> GridColumns
{
get { return m_columns; }
set
{
m_columns = value;
if (value != null)
intWidth = value.Sum(p => p.WidthType == SizeType.Absolute ? p.Width : (p.Width < ? : p.Width));
}
}
private List<object> m_dataSource = null; [Description("表格数据源"), Category("自定义")]
public List<object> GridDataSource
{
get { return m_dataSource; }
set { m_dataSource = value; }
} private string m_textField; [Description("显示值字段名称"), Category("自定义")]
public string TextField
{
get { return m_textField; }
set
{
m_textField = value;
SetText();
}
}
[Obsolete("不再可用的属性")]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
private new ComboBoxStyle BoxStyle
{
get;
set;
}
private object selectSource = null; [Description("选中的数据源"), Category("自定义")]
public object SelectSource
{
get { return selectSource; }
set
{
selectSource = value;
SetText();
if (SelectedChangedEvent != null)
{
SelectedChangedEvent(value, null);
}
}
} [Description("选中数据源改变事件"), Category("自定义")]
public new event EventHandler SelectedChangedEvent;
public UCComboxGrid()
{
InitializeComponent();
}
UCComboxGridPanel m_ucPanel = null;
Forms.FrmAnchor _frmAnchor;
protected override void click_MouseDown(object sender, MouseEventArgs e)
{
if (m_columns == null || m_columns.Count <= )
return;
if (m_ucPanel == null)
{
var p = this.Parent.PointToScreen(this.Location);
int intScreenHeight = Screen.PrimaryScreen.Bounds.Height;
int intHeight = Math.Max(p.Y, intScreenHeight - p.Y - this.Height);
intHeight -= ;
m_ucPanel = new UCComboxGridPanel();
m_ucPanel.ItemClick += m_ucPanel_ItemClick;
m_ucPanel.Height = intHeight;
m_ucPanel.Width = intWidth;
m_ucPanel.Columns = m_columns;
m_ucPanel.RowType = m_rowType;
if (m_dataSource != null && m_dataSource.Count > )
{
int _intHeight = Math.Min( + m_dataSource.Count * , m_ucPanel.Height);
m_ucPanel.Height = _intHeight;
}
}
m_ucPanel.DataSource = m_dataSource;
if (_frmAnchor == null || _frmAnchor.IsDisposed || _frmAnchor.Visible == false)
{
_frmAnchor = new Forms.FrmAnchor(this, m_ucPanel);
_frmAnchor.Show(this.FindForm());
} } void m_ucPanel_ItemClick(object sender, DataGridViewEventArgs e)
{
_frmAnchor.Hide();
SelectSource = sender;
} private void SetText()
{
if (!string.IsNullOrEmpty(m_textField) && selectSource != null)
{
var pro = selectSource.GetType().GetProperty(m_textField);
if (pro != null)
{
TextValue = pro.GetValue(selectSource, null).ToStringExt();
}
}
}
}
}
 namespace HZH_Controls.Controls.ComboBox
{
partial class UCComboxGrid
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region 组件设计器生成的代码 /// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// txtInput
//
this.txtInput.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
//
// UCComboxGrid
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.Transparent;
this.BoxStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.Name = "UCComboxGrid";
this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.ResumeLayout(false);
this.PerformLayout(); } #endregion }
}

以上就是全部东西了

最后的话

如果你喜欢的话,请到 https://gitee.com/kwwwvagaa/net_winform_custom_control 点个星星吧

(四十九)c#Winform自定义控件-下拉框(表格)的更多相关文章

  1. (三十五)c#Winform自定义控件-下拉框

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  2. (四十八)c#Winform自定义控件-下拉按钮

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  3. android+myeclipse+mysql自定义控件下拉框的数据绑定

    原创作品,允许转载,转载时请务必声明作者信息和本声明.http://www.cnblogs.com/zhu520/p/8031936.html 本人小白,那个大神看到有问题可指出,谢谢.... 这个是 ...

  4. C# Winform 获得下拉框 选中的值

    string PrintName = cmbPrinter.SelectedIndex.ToString(); PrintName = cmbPrinter.SelectedItem.ToString ...

  5. LigerUI ligerComboBox 下拉框 表格 多选无效

    $("#txt1").ligerComboBox({ width: 250, slide: false, selectBoxWidth: 500, selectBoxHeight: ...

  6. (四十九)Quartz2D自定义控件

    利用Quartz2D来自定义UIImageView: 模仿UIImageView: 设置frame,设置图片. 注意一个细节,自定义的imageView,应该通过重写set方法来设置图片并且重绘,否则 ...

  7. (四十)c#Winform自定义控件-开关-HZHControls

    官网 http://www.hzhcontrols.com 前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kww ...

  8. 第二百二十四节,jQuery EasyUI,ComboGrid(数据表格下拉框)组件

    jQuery EasyUI,ComboGrid(数据表格下拉框)组件 学习要点: 1.加载方式 2.属性列表 3.方法列表 本节课重点了解 EasyUI 中 ComboGrid(数据表格下拉框)组件的 ...

  9. “全栈2019”Java第四十九章:重载与重写对比详解

    难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...

随机推荐

  1. iOS程序员如何提升核心竞争力,防止自己被裁员?

    前言: 核心竞争力最早由普拉哈拉德和加里·哈默尔两位教授提出,通常认为核心竞争力,即企业或个人相较于竞争对手而言所具备的竞争优势与核心能力差异,说白了就是你的优势,而且最好是独一无二的的优势,这就是核 ...

  2. 一文了解有趣的位运算(&、|、^、~、>>、<<)

    1.位运算概述 从现代计算机中所有的数据二进制的形式存储在设备中.即0.1两种状态,计算机对二进制数据进行的运算(+.-.*./)都是叫位运算,即将符号位共同参与运算的运算. 口说无凭,举一个简单的例 ...

  3. linux初学者-firewall篇

     linux初学者-firewall篇 firewalld是防火墙的另一种程序,与iptables相同,但是使用起来要比iptables简单的点,不需要了解3张表和5条链也可以使用. 1.firewa ...

  4. JasperReport报表

    最近在做报表工作,公司要求使用正版免费的报表软件,想想还是用JasperReport. JasperReport是一个纯Java写的开源免费报表工具库,在java开源免费报表中,排在前列. 可是开源免 ...

  5. java练习---10

    package cn.zrjh; public class L { public int id; public String name; public int age; public String c ...

  6. 关于JLINK调试时出现的 erasing range....的问题结果方法

    声明:本人当然不是提倡盗版. 昨天在使用JLINK的时候遇到了这个问题,但是非常蹊跷,首先可以下载,但不能进入调试,到后来完成不能下载了. 这个问题的原因就是你得Keil检测到你锁使用的JLINK不是 ...

  7. 数据结构与算法基础之malloc()动态分配内存概述

    动态内存分配和释放: 动态构造一维数组: 假设动态构造一个Int型数组: int *p = (int *)malloc(int len); //还可以写作: int *p = (int *)mallo ...

  8. the license has been canceled

    ideal 的 注册码并没有失效,却显示这个信息 the license has been canceled 如果用的是Windows系统,在hosts文件添加下边的ip及映射 0.0.0.0 acc ...

  9. 实时同步lsyncd

    实时同步lsyncd 1 lsyncd 1.1 lsyncd 简介 Lsyncd使用文件系统事件接口(inotify或fsevents)来监视对本地文件和目录的更改.Lsyncd将这些事件整理几秒钟, ...

  10. weblogic 内存溢出解决 java.lang.OutOfMemoryError: PermGen space

    解决办法: 1.在idea中,运行时给weblogic server中 VM options 配置增加内存的参数:-server -XX:PermSize=1024m -XX:MaxPermSize= ...