Commit 35ef5cf9 HZH

add comboxgrid

1 个父辈 cd36457d
namespace HZH_Controls.Controls namespace HZH_Controls.Controls
{ {
partial class UCComboBox partial class UCCombox
{ {
/// <summary> /// <summary>
/// 必需的设计器变量。 /// 必需的设计器变量。
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// 清理所有正在使用的资源。 /// 清理所有正在使用的资源。
/// </summary> /// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region 组件设计器生成的代码 #region 组件设计器生成的代码
/// <summary> /// <summary>
/// 设计器支持所需的方法 - 不要 /// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。 /// 使用代码编辑器修改此方法的内容。
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.txtInput = new HZH_Controls.Controls.TextBoxEx(); this.txtInput = new HZH_Controls.Controls.TextBoxEx();
this.lblInput = new System.Windows.Forms.Label(); this.lblInput = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// panel1 // panel1
// //
this.panel1.BackColor = System.Drawing.Color.Transparent; this.panel1.BackColor = System.Drawing.Color.Transparent;
this.panel1.BackgroundImage = global::HZH_Controls.Properties.Resources.ComboBox; this.panel1.BackgroundImage = global::HZH_Controls.Properties.Resources.ComboBox;
this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.panel1.Dock = System.Windows.Forms.DockStyle.Right; this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
this.panel1.Location = new System.Drawing.Point(136, 0); this.panel1.Location = new System.Drawing.Point(136, 0);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(37, 32); this.panel1.Size = new System.Drawing.Size(37, 32);
this.panel1.TabIndex = 0; this.panel1.TabIndex = 0;
this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.click_MouseDown); this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.click_MouseDown);
// //
// txtInput // txtInput
// //
this.txtInput.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.txtInput.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.txtInput.BackColor = System.Drawing.Color.White; this.txtInput.BackColor = System.Drawing.Color.White;
this.txtInput.BorderStyle = System.Windows.Forms.BorderStyle.None; this.txtInput.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.txtInput.DecLength = 2; this.txtInput.DecLength = 2;
this.txtInput.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.txtInput.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.txtInput.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.txtInput.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.txtInput.InputType = TextInputType.NotControl; this.txtInput.InputType = HZH_Controls.TextInputType.NotControl;
this.txtInput.Location = new System.Drawing.Point(3, 4); this.txtInput.Location = new System.Drawing.Point(3, 4);
this.txtInput.Margin = new System.Windows.Forms.Padding(3, 3, 10, 3); this.txtInput.Margin = new System.Windows.Forms.Padding(3, 3, 10, 3);
this.txtInput.MaxValue = new decimal(new int[] { this.txtInput.MaxValue = new decimal(new int[] {
1000000, 1000000,
0, 0,
0, 0,
0}); 0});
this.txtInput.MinValue = new decimal(new int[] { this.txtInput.MinValue = new decimal(new int[] {
1000000, 1000000,
0, 0,
0, 0,
-2147483648}); -2147483648});
this.txtInput.MyRectangle = new System.Drawing.Rectangle(0, 0, 0, 0); this.txtInput.MyRectangle = new System.Drawing.Rectangle(0, 0, 0, 0);
this.txtInput.Name = "txtInput"; this.txtInput.Name = "txtInput";
this.txtInput.OldText = null; this.txtInput.OldText = null;
this.txtInput.PromptColor = System.Drawing.Color.Silver; this.txtInput.PromptColor = System.Drawing.Color.Silver;
this.txtInput.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.txtInput.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.txtInput.PromptText = ""; this.txtInput.PromptText = "";
this.txtInput.RegexPattern = ""; this.txtInput.RegexPattern = "";
this.txtInput.Size = new System.Drawing.Size(133, 24); this.txtInput.Size = new System.Drawing.Size(133, 24);
this.txtInput.TabIndex = 1; this.txtInput.TabIndex = 1;
this.txtInput.TextChanged += new System.EventHandler(this.txtInput_TextChanged); this.txtInput.TextChanged += new System.EventHandler(this.txtInput_TextChanged);
// //
// lblInput // lblInput
// //
this.lblInput.AutoSize = true; this.lblInput.AutoSize = true;
this.lblInput.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.lblInput.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.lblInput.Location = new System.Drawing.Point(3, 6); this.lblInput.Location = new System.Drawing.Point(3, 6);
this.lblInput.Name = "lblInput"; this.lblInput.Name = "lblInput";
this.lblInput.Size = new System.Drawing.Size(0, 20); this.lblInput.Size = new System.Drawing.Size(0, 20);
this.lblInput.TabIndex = 2; this.lblInput.TabIndex = 2;
this.lblInput.Visible = false; this.lblInput.Visible = false;
this.lblInput.MouseDown += new System.Windows.Forms.MouseEventHandler(this.click_MouseDown); this.lblInput.MouseDown += new System.Windows.Forms.MouseEventHandler(this.click_MouseDown);
// //
// UCComboBox // UCCombox
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.Transparent; this.BackColor = System.Drawing.Color.Transparent;
this.ConerRadius = 5; this.ConerRadius = 5;
this.Controls.Add(this.panel1); this.Controls.Add(this.panel1);
this.Controls.Add(this.txtInput); this.Controls.Add(this.txtInput);
this.Controls.Add(this.lblInput); this.Controls.Add(this.lblInput);
this.FillColor = System.Drawing.Color.Gainsboro; this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.IsShowRect = true; this.IsShowRect = true;
this.Name = "UCComboBox"; this.Name = "UCCombox";
this.Size = new System.Drawing.Size(173, 32); this.Size = new System.Drawing.Size(173, 32);
this.Load += new System.EventHandler(this.UCComboBox_Load); this.Load += new System.EventHandler(this.UCComboBox_Load);
this.SizeChanged += new System.EventHandler(this.UCComboBox_SizeChanged); this.SizeChanged += new System.EventHandler(this.UCComboBox_SizeChanged);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.click_MouseDown); this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.click_MouseDown);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
} }
#endregion #endregion
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel1;
public TextBoxEx txtInput; public TextBoxEx txtInput;
private System.Windows.Forms.Label lblInput; private System.Windows.Forms.Label lblInput;
} }
} }
// 版权所有 黄正辉 交流群:568015492 QQ:623128629 // 版权所有 黄正辉 交流群:568015492 QQ:623128629
// 文件名称:UCComboBox.cs // 文件名称:UCComboBox.cs
// 创建日期:2019-08-15 15:58:51 // 创建日期:2019-08-15 15:58:51
// 功能描述:ComboBox // 功能描述:ComboBox
// 项目地址:https://gitee.com/kwwwvagaa/net_winform_custom_control // 项目地址:https://gitee.com/kwwwvagaa/net_winform_custom_control
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
namespace HZH_Controls.Controls namespace HZH_Controls.Controls
{ {
[DefaultEvent("SelectedChangedEvent")] [DefaultEvent("SelectedChangedEvent")]
public partial class UCComboBox : UCControlBase public partial class UCCombox : UCControlBase
{ {
Color _ForeColor = Color.FromArgb(64, 64, 64); Color _ForeColor = Color.FromArgb(64, 64, 64);
[Description("文字颜色"), Category("自定义")] [Description("文字颜色"), Category("自定义")]
public override Color ForeColor public override Color ForeColor
{ {
get get
{ {
return _ForeColor; return _ForeColor;
} }
set set
{ {
_ForeColor = value; _ForeColor = value;
lblInput.ForeColor = value; lblInput.ForeColor = value;
txtInput.ForeColor = value; txtInput.ForeColor = value;
} }
} }
public event EventHandler SelectedChangedEvent; public event EventHandler SelectedChangedEvent;
public event EventHandler TextChangedEvent; public event EventHandler TextChangedEvent;
private ComboBoxStyle _BoxStyle = ComboBoxStyle.DropDown; private ComboBoxStyle _BoxStyle = ComboBoxStyle.DropDown;
[Description("控件样式"), Category("自定义")] [Description("控件样式"), Category("自定义")]
public ComboBoxStyle BoxStyle public ComboBoxStyle BoxStyle
{ {
get { return _BoxStyle; } get { return _BoxStyle; }
set set
{ {
_BoxStyle = value; _BoxStyle = value;
if (value == ComboBoxStyle.DropDownList) if (value == ComboBoxStyle.DropDownList)
{ {
lblInput.Visible = true; lblInput.Visible = true;
txtInput.Visible = false; txtInput.Visible = false;
} }
else else
{ {
lblInput.Visible = false; lblInput.Visible = false;
txtInput.Visible = true; txtInput.Visible = true;
} }
if (this._BoxStyle == ComboBoxStyle.DropDownList) if (this._BoxStyle == ComboBoxStyle.DropDownList)
{ {
txtInput.BackColor = _BackColor; txtInput.BackColor = _BackColor;
base.FillColor = _BackColor; base.FillColor = _BackColor;
base.RectColor = _BackColor; base.RectColor = _BackColor;
} }
else else
{ {
txtInput.BackColor = Color.White; txtInput.BackColor = Color.White;
base.FillColor = Color.White; base.FillColor = Color.White;
base.RectColor = Color.FromArgb(220, 220, 220); base.RectColor = Color.FromArgb(220, 220, 220);
} }
} }
} }
private Font _Font = new Font("微软雅黑", 12); private Font _Font = new Font("微软雅黑", 12);
[Description("字体"), Category("自定义")] [Description("字体"), Category("自定义")]
public new Font Font public new Font Font
{ {
get { return _Font; } get { return _Font; }
set set
{ {
_Font = value; _Font = value;
lblInput.Font = value; lblInput.Font = value;
txtInput.Font = value; txtInput.Font = value;
txtInput.PromptFont = value; txtInput.PromptFont = value;
this.txtInput.Location = new Point(this.txtInput.Location.X, (this.Height - txtInput.Height) / 2); this.txtInput.Location = new Point(this.txtInput.Location.X, (this.Height - txtInput.Height) / 2);
this.lblInput.Location = new Point(this.lblInput.Location.X, (this.Height - lblInput.Height) / 2); this.lblInput.Location = new Point(this.lblInput.Location.X, (this.Height - lblInput.Height) / 2);
} }
} }
[Obsolete("不再可用的属性")] [Obsolete("不再可用的属性")]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
private new Color FillColor private new Color FillColor
{ {
get; get;
set; set;
} }
[Obsolete("不再可用的属性")] [Obsolete("不再可用的属性")]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
private new Color RectColor private new Color RectColor
{ {
get; get;
set; set;
} }
private string _TextValue; private string _TextValue;
public string TextValue public string TextValue
{ {
get { return _TextValue; } get { return _TextValue; }
set set
{ {
_TextValue = value; _TextValue = value;
if (lblInput.Text != value) if (lblInput.Text != value)
lblInput.Text = value; lblInput.Text = value;
if (txtInput.Text != value) if (txtInput.Text != value)
txtInput.Text = value; txtInput.Text = value;
} }
} }
private List<KeyValuePair<string, string>> _source = null; private List<KeyValuePair<string, string>> _source = null;
public List<KeyValuePair<string, string>> Source public List<KeyValuePair<string, string>> Source
{ {
get { return _source; } get { return _source; }
set set
{ {
_source = value; _source = value;
_selectedIndex = -1; _selectedIndex = -1;
_selectedValue = ""; _selectedValue = "";
_selectedItem = new KeyValuePair<string, string>(); _selectedItem = new KeyValuePair<string, string>();
_selectedText = ""; _selectedText = "";
lblInput.Text = ""; lblInput.Text = "";
txtInput.Text = ""; txtInput.Text = "";
} }
} }
private KeyValuePair<string, string> _selectedItem = new KeyValuePair<string, string>(); private KeyValuePair<string, string> _selectedItem = new KeyValuePair<string, string>();
private int _selectedIndex = -1; private int _selectedIndex = -1;
public int SelectedIndex public int SelectedIndex
{ {
get get
{ {
return _selectedIndex; return _selectedIndex;
} }
set set
{ {
if (value < 0 || _source == null || _source.Count <= 0 || value >= _source.Count) if (value < 0 || _source == null || _source.Count <= 0 || value >= _source.Count)
{ {
_selectedIndex = -1; _selectedIndex = -1;
_selectedValue = ""; _selectedValue = "";
_selectedItem = new KeyValuePair<string, string>(); _selectedItem = new KeyValuePair<string, string>();
SelectedText = ""; SelectedText = "";
} }
else else
{ {
_selectedIndex = value; _selectedIndex = value;
_selectedItem = _source[value]; _selectedItem = _source[value];
_selectedValue = _source[value].Key; _selectedValue = _source[value].Key;
SelectedText = _source[value].Value; SelectedText = _source[value].Value;
} }
} }
} }
private string _selectedValue = ""; private string _selectedValue = "";
public string SelectedValue public string SelectedValue
{ {
get get
{ {
return _selectedValue; return _selectedValue;
} }
set set
{ {
if (_source == null || _source.Count <= 0) if (_source == null || _source.Count <= 0)
{ {
SelectedText = ""; SelectedText = "";
_selectedValue = ""; _selectedValue = "";
_selectedIndex = -1; _selectedIndex = -1;
_selectedItem = new KeyValuePair<string, string>(); _selectedItem = new KeyValuePair<string, string>();
} }
else else
{ {
for (int i = 0; i < _source.Count; i++) for (int i = 0; i < _source.Count; i++)
{ {
if (_source[i].Key == value) if (_source[i].Key == value)
{ {
_selectedValue = value; _selectedValue = value;
_selectedIndex = i; _selectedIndex = i;
_selectedItem = _source[i]; _selectedItem = _source[i];
SelectedText = _source[i].Value; SelectedText = _source[i].Value;
return; return;
} }
} }
_selectedValue = ""; _selectedValue = "";
_selectedIndex = -1; _selectedIndex = -1;
_selectedItem = new KeyValuePair<string, string>(); _selectedItem = new KeyValuePair<string, string>();
SelectedText = ""; SelectedText = "";
} }
} }
} }
private string _selectedText = ""; private string _selectedText = "";
public string SelectedText public string SelectedText
{ {
get { return _selectedText; } get { return _selectedText; }
private set private set
{ {
_selectedText = value; _selectedText = value;
lblInput.Text = _selectedText; lblInput.Text = _selectedText;
txtInput.Text = _selectedText; txtInput.Text = _selectedText;
if (SelectedChangedEvent != null) if (SelectedChangedEvent != null)
{ {
SelectedChangedEvent(this, null); SelectedChangedEvent(this, null);
} }
} }
} }
private int _ItemWidth = 70; private int _ItemWidth = 70;
public int ItemWidth public int ItemWidth
{ {
get { return _ItemWidth; } get { return _ItemWidth; }
set { _ItemWidth = value; } set { _ItemWidth = value; }
} }
private int _dropPanelHeight = -1; private int _dropPanelHeight = -1;
public int DropPanelHeight public int DropPanelHeight
{ {
get { return _dropPanelHeight; } get { return _dropPanelHeight; }
set { _dropPanelHeight = value; } set { _dropPanelHeight = value; }
} }
[Obsolete("不再可用的属性,如需要改变背景色,请使用BackColorExt")] [Obsolete("不再可用的属性,如需要改变背景色,请使用BackColorExt")]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
private new Color BackColor private new Color BackColor
{ {
get get
{ {
return base.BackColor; return base.BackColor;
} }
set set
{ {
base.BackColor = Color.Transparent; base.BackColor = Color.Transparent;
} }
} }
private Color _BackColor = Color.FromArgb(240, 240, 240); private Color _BackColor = Color.FromArgb(240, 240, 240);
public Color BackColorExt public Color BackColorExt
{ {
get get
{ {
return _BackColor; return _BackColor;
} }
set set
{ {
if (value == Color.Transparent) if (value == Color.Transparent)
return; return;
_BackColor = value; _BackColor = value;
lblInput.BackColor = value; lblInput.BackColor = value;
if (this._BoxStyle == ComboBoxStyle.DropDownList) if (this._BoxStyle == ComboBoxStyle.DropDownList)
{ {
txtInput.BackColor = value; txtInput.BackColor = value;
base.FillColor = value; base.FillColor = value;
base.RectColor = value; base.RectColor = value;
} }
else else
{ {
txtInput.BackColor = Color.White; txtInput.BackColor = Color.White;
base.FillColor = Color.White; base.FillColor = Color.White;
base.RectColor = Color.FromArgb(220, 220, 220); base.RectColor = Color.FromArgb(220, 220, 220);
} }
} }
} }
public UCComboBox() public UCCombox()
{ {
InitializeComponent(); InitializeComponent();
lblInput.BackColor = _BackColor; lblInput.BackColor = _BackColor;
if (this._BoxStyle == ComboBoxStyle.DropDownList) if (this._BoxStyle == ComboBoxStyle.DropDownList)
{ {
txtInput.BackColor = _BackColor; txtInput.BackColor = _BackColor;
base.FillColor = _BackColor; base.FillColor = _BackColor;
base.RectColor = _BackColor; base.RectColor = _BackColor;
} }
else else
{ {
txtInput.BackColor = Color.White; txtInput.BackColor = Color.White;
base.FillColor = Color.White; base.FillColor = Color.White;
base.RectColor = Color.FromArgb(220, 220, 220); base.RectColor = Color.FromArgb(220, 220, 220);
} }
base.BackColor = Color.Transparent; base.BackColor = Color.Transparent;
} }
private void UCComboBox_SizeChanged(object sender, EventArgs e) private void UCComboBox_SizeChanged(object sender, EventArgs e)
{ {
this.txtInput.Location = new Point(this.txtInput.Location.X, (this.Height - txtInput.Height) / 2); this.txtInput.Location = new Point(this.txtInput.Location.X, (this.Height - txtInput.Height) / 2);
this.lblInput.Location = new Point(this.lblInput.Location.X, (this.Height - lblInput.Height) / 2); this.lblInput.Location = new Point(this.lblInput.Location.X, (this.Height - lblInput.Height) / 2);
} }
private void txtInput_TextChanged(object sender, EventArgs e) private void txtInput_TextChanged(object sender, EventArgs e)
{ {
TextValue = txtInput.Text; TextValue = txtInput.Text;
if (TextChangedEvent != null) if (TextChangedEvent != null)
{ {
TextChangedEvent(this, null); TextChangedEvent(this, null);
} }
} }
private void click_MouseDown(object sender, MouseEventArgs e) protected virtual void click_MouseDown(object sender, MouseEventArgs e)
{ {
if (_frmAnchor == null || _frmAnchor.IsDisposed || _frmAnchor.Visible == false) if (_frmAnchor == null || _frmAnchor.IsDisposed || _frmAnchor.Visible == false)
{ {
if (this.Source != null && this.Source.Count > 0) if (this.Source != null && this.Source.Count > 0)
{ {
int intRow = 0; int intRow = 0;
int intCom = 1; int intCom = 1;
var p = this.PointToScreen(this.Location); var p = this.PointToScreen(this.Location);
while (true) while (true)
{ {
int intScreenHeight = Screen.PrimaryScreen.Bounds.Height; int intScreenHeight = Screen.PrimaryScreen.Bounds.Height;
if ((p.Y + this.Height + this.Source.Count / intCom * 50 < intScreenHeight || p.Y - this.Source.Count / intCom * 50 > 0) if ((p.Y + this.Height + this.Source.Count / intCom * 50 < intScreenHeight || p.Y - this.Source.Count / intCom * 50 > 0)
&& (_dropPanelHeight <= 0 ? true : (this.Source.Count / intCom * 50 <= _dropPanelHeight))) && (_dropPanelHeight <= 0 ? true : (this.Source.Count / intCom * 50 <= _dropPanelHeight)))
{ {
intRow = this.Source.Count / intCom + (this.Source.Count % intCom != 0 ? 1 : 0); intRow = this.Source.Count / intCom + (this.Source.Count % intCom != 0 ? 1 : 0);
break; break;
} }
intCom++; intCom++;
} }
UCTimePanel ucTime = new UCTimePanel(); UCTimePanel ucTime = new UCTimePanel();
ucTime.IsShowBorder = true; ucTime.IsShowBorder = true;
int intWidth = this.Width / intCom; int intWidth = this.Width / intCom;
if (intWidth < _ItemWidth) if (intWidth < _ItemWidth)
intWidth = _ItemWidth; intWidth = _ItemWidth;
Size size = new Size(intCom * intWidth, intRow * 50); Size size = new Size(intCom * intWidth, intRow * 50);
ucTime.Size = size; ucTime.Size = size;
ucTime.FirstEvent = true; ucTime.FirstEvent = true;
ucTime.SelectSourceEvent += ucTime_SelectSourceEvent; ucTime.SelectSourceEvent += ucTime_SelectSourceEvent;
ucTime.Row = intRow; ucTime.Row = intRow;
ucTime.Column = intCom; ucTime.Column = intCom;
List<KeyValuePair<string, string>> lst = new List<KeyValuePair<string, string>>(); List<KeyValuePair<string, string>> lst = new List<KeyValuePair<string, string>>();
foreach (var item in this.Source) foreach (var item in this.Source)
{ {
lst.Add(new KeyValuePair<string, string>(item.Key, item.Value)); lst.Add(new KeyValuePair<string, string>(item.Key, item.Value));
} }
ucTime.Source = lst; ucTime.Source = lst;
ucTime.SetSelect(_selectedValue); ucTime.SetSelect(_selectedValue);
_frmAnchor = new Forms.FrmAnchor(this, ucTime); _frmAnchor = new Forms.FrmAnchor(this, ucTime);
_frmAnchor.Load += (a, b) => { (a as Form).Size = size; }; _frmAnchor.Load += (a, b) => { (a as Form).Size = size; };
_frmAnchor.Show(this.FindForm()); _frmAnchor.Show(this.FindForm());
} }
} }
else else
{ {
_frmAnchor.Close(); _frmAnchor.Close();
} }
} }
Forms.FrmAnchor _frmAnchor; Forms.FrmAnchor _frmAnchor;
void ucTime_SelectSourceEvent(object sender, EventArgs e) void ucTime_SelectSourceEvent(object sender, EventArgs e)
{ {
if (_frmAnchor != null && !_frmAnchor.IsDisposed && _frmAnchor.Visible) if (_frmAnchor != null && !_frmAnchor.IsDisposed && _frmAnchor.Visible)
{ {
SelectedValue = sender.ToString(); SelectedValue = sender.ToString();
_frmAnchor.Close(); _frmAnchor.Close();
} }
} }
private void UCComboBox_Load(object sender, EventArgs e) private void UCComboBox_Load(object sender, EventArgs e)
{ {
if (this._BoxStyle == ComboBoxStyle.DropDownList) if (this._BoxStyle == ComboBoxStyle.DropDownList)
{ {
txtInput.BackColor = _BackColor; txtInput.BackColor = _BackColor;
base.FillColor = _BackColor; base.FillColor = _BackColor;
base.RectColor = _BackColor; base.RectColor = _BackColor;
} }
else else
{ {
txtInput.BackColor = Color.White; txtInput.BackColor = Color.White;
base.FillColor = Color.White; base.FillColor = Color.White;
base.RectColor = Color.FromArgb(220, 220, 220); base.RectColor = Color.FromArgb(220, 220, 220);
} }
} }
} }
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata"> <xsd:element name="metadata">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
<xsd:complexType> <xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="data"> <xsd:element name="data">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:choice> </xsd:choice>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:schema> </xsd:schema>
<resheader name="resmimetype"> <resheader name="resmimetype">
<value>text/microsoft-resx</value> <value>text/microsoft-resx</value>
</resheader> </resheader>
<resheader name="version"> <resheader name="version">
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
</root> </root>
\ No newline at end of file \ No newline at end of file
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)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
//
// 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)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.Name = "UCComboxGrid";
this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
}
}
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 = 0;
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 < 80 ? 80 : 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);
}
}
}
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();
}
}
}
[Description("选中数据源改变事件"), Category("自定义")]
public 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 <= 0)
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 -= 100;
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 > 0)
{
int _intHeight = Math.Min(110 + m_dataSource.Count * 36, 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;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
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.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.timer1 = new System.Windows.Forms.Timer();
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(1, 1);
this.panel1.Name = "panel1";
this.panel1.Padding = new System.Windows.Forms.Padding(5);
this.panel1.Size = new System.Drawing.Size(447, 333);
this.panel1.TabIndex = 4;
//
// panel2
//
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
this.panel2.Location = new System.Drawing.Point(5, 47);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(437, 15);
this.panel2.TabIndex = 1;
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// ucControlBase1
//
this.ucControlBase1.ConerRadius = 5;
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(5, 62);
this.ucControlBase1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucControlBase1.Name = "ucControlBase1";
this.ucControlBase1.Padding = new System.Windows.Forms.Padding(5);
this.ucControlBase1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
this.ucControlBase1.RectWidth = 1;
this.ucControlBase1.Size = new System.Drawing.Size(437, 266);
this.ucControlBase1.TabIndex = 2;
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 = 40;
this.ucDataGridView1.HeadPadingLeft = 0;
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(5, 5);
this.ucDataGridView1.Name = "ucDataGridView1";
this.ucDataGridView1.Page = null;
this.ucDataGridView1.RowHeight = 30;
this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDataGridView1.Size = new System.Drawing.Size(427, 256);
this.ucDataGridView1.TabIndex = 0;
this.ucDataGridView1.TabStop = false;
//
// txtSearch
//
this.txtSearch.BackColor = System.Drawing.Color.Transparent;
this.txtSearch.ConerRadius = 5;
this.txtSearch.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtSearch.DecLength = 2;
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(5, 5);
this.txtSearch.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtSearch.MaxValue = new decimal(new int[] {
1000000,
0,
0,
0});
this.txtSearch.MinValue = new decimal(new int[] {
1000000,
0,
0,
-2147483648});
this.txtSearch.Name = "txtSearch";
this.txtSearch.Padding = new System.Windows.Forms.Padding(5);
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)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
this.txtSearch.RectWidth = 1;
this.txtSearch.RegexPattern = "";
this.txtSearch.Size = new System.Drawing.Size(437, 42);
this.txtSearch.TabIndex = 0;
//
// ucSplitLine_V2
//
this.ucSplitLine_V2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
this.ucSplitLine_V2.Dock = System.Windows.Forms.DockStyle.Right;
this.ucSplitLine_V2.Location = new System.Drawing.Point(448, 1);
this.ucSplitLine_V2.Name = "ucSplitLine_V2";
this.ucSplitLine_V2.Size = new System.Drawing.Size(1, 333);
this.ucSplitLine_V2.TabIndex = 3;
this.ucSplitLine_V2.TabStop = false;
//
// ucSplitLine_V1
//
this.ucSplitLine_V1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
this.ucSplitLine_V1.Dock = System.Windows.Forms.DockStyle.Left;
this.ucSplitLine_V1.Location = new System.Drawing.Point(0, 1);
this.ucSplitLine_V1.Name = "ucSplitLine_V1";
this.ucSplitLine_V1.Size = new System.Drawing.Size(1, 333);
this.ucSplitLine_V1.TabIndex = 2;
this.ucSplitLine_V1.TabStop = false;
//
// ucSplitLine_H2
//
this.ucSplitLine_H2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
this.ucSplitLine_H2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.ucSplitLine_H2.Location = new System.Drawing.Point(0, 334);
this.ucSplitLine_H2.Name = "ucSplitLine_H2";
this.ucSplitLine_H2.Size = new System.Drawing.Size(449, 1);
this.ucSplitLine_H2.TabIndex = 1;
this.ucSplitLine_H2.TabStop = false;
//
// ucSplitLine_H1
//
this.ucSplitLine_H1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
this.ucSplitLine_H1.Dock = System.Windows.Forms.DockStyle.Top;
this.ucSplitLine_H1.Location = new System.Drawing.Point(0, 0);
this.ucSplitLine_H1.Name = "ucSplitLine_H1";
this.ucSplitLine_H1.Size = new System.Drawing.Size(449, 1);
this.ucSplitLine_H1.TabIndex = 0;
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(449, 335);
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;
}
}
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 = 0;
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();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file \ No newline at end of file
...@@ -81,7 +81,6 @@ ...@@ -81,7 +81,6 @@
// //
// panRow // panRow
// //
this.panRow.AutoScroll = true;
this.panRow.Dock = System.Windows.Forms.DockStyle.Fill; this.panRow.Dock = System.Windows.Forms.DockStyle.Fill;
this.panRow.Location = new System.Drawing.Point(0, 40); this.panRow.Location = new System.Drawing.Point(0, 40);
this.panRow.Name = "panRow"; this.panRow.Name = "panRow";
......
...@@ -167,7 +167,9 @@ namespace HZH_Controls.Controls ...@@ -167,7 +167,9 @@ namespace HZH_Controls.Controls
} }
m_dataSource = value; m_dataSource = value;
if (m_columns != null && m_columns.Count > 0) if (m_columns != null && m_columns.Count > 0)
{
ReloadSource(); ReloadSource();
}
} }
} }
...@@ -222,17 +224,22 @@ namespace HZH_Controls.Controls ...@@ -222,17 +224,22 @@ namespace HZH_Controls.Controls
List<IDataGridViewRow> lst = new List<IDataGridViewRow>(); List<IDataGridViewRow> lst = new List<IDataGridViewRow>();
if (m_isShowCheckBox) if (m_isShowCheckBox)
{ {
lst.AddRange(Rows.FindAll(p => p.IsChecked)); if (Rows != null && Rows.Count > 0)
lst.AddRange(Rows.FindAll(p => p.IsChecked));
} }
else else
{ {
lst.AddRange(new List<IDataGridViewRow>() { m_selectRow }); if (m_selectRow != null)
lst.AddRange(new List<IDataGridViewRow>() { m_selectRow });
} }
foreach (var row in Rows) if (Rows != null && Rows.Count > 0)
{ {
Control c = row as Control; foreach (var row in Rows)
UCDataGridView grid = FindChildGrid(c); {
lst.AddRange(grid.SelectRows); Control c = row as Control;
UCDataGridView grid = FindChildGrid(c);
lst.AddRange(grid.SelectRows);
}
} }
return lst; return lst;
} }
...@@ -271,6 +278,7 @@ namespace HZH_Controls.Controls ...@@ -271,6 +278,7 @@ namespace HZH_Controls.Controls
panPage.Visible = value != null; panPage.Visible = value != null;
m_page.ShowSourceChanged += page_ShowSourceChanged; m_page.ShowSourceChanged += page_ShowSourceChanged;
m_page.Dock = DockStyle.Fill; m_page.Dock = DockStyle.Fill;
//this.panPage.Height = value.Height;
this.panPage.Controls.Clear(); this.panPage.Controls.Clear();
this.panPage.Controls.Add(m_page); this.panPage.Controls.Add(m_page);
ResetShowCount(); ResetShowCount();
...@@ -292,7 +300,11 @@ namespace HZH_Controls.Controls ...@@ -292,7 +300,11 @@ namespace HZH_Controls.Controls
public bool IsAutoHeight public bool IsAutoHeight
{ {
get { return m_isAutoHeight; } get { return m_isAutoHeight; }
set { m_isAutoHeight = value; } set
{
m_isAutoHeight = value;
this.AutoScroll = value;
}
} }
void page_ShowSourceChanged(object currentSource) void page_ShowSourceChanged(object currentSource)
...@@ -432,7 +444,6 @@ namespace HZH_Controls.Controls ...@@ -432,7 +444,6 @@ namespace HZH_Controls.Controls
ControlHelper.FreezeControl(this.panRow, true); ControlHelper.FreezeControl(this.panRow, true);
this.panRow.Controls.Clear(); this.panRow.Controls.Clear();
Rows = new List<IDataGridViewRow>(); Rows = new List<IDataGridViewRow>();
if (m_columns == null || m_columns.Count <= 0) if (m_columns == null || m_columns.Count <= 0)
return; return;
...@@ -505,7 +516,7 @@ namespace HZH_Controls.Controls ...@@ -505,7 +516,7 @@ namespace HZH_Controls.Controls
this.panRow.Controls.Add(rowControl); this.panRow.Controls.Add(rowControl);
row.RowHeight = m_rowHeight; row.RowHeight = m_rowHeight;
rowControl.Dock = DockStyle.Top; rowControl.Dock = DockStyle.Top;
row.CellClick += (a, b) => { SetSelectRow((Control)a, b); }; row.CellClick += (a, b) => { SetSelectRow(rowControl, b); };
row.CheckBoxChangeEvent += (a, b) => { SetSelectRow(rowControl, b); }; row.CheckBoxChangeEvent += (a, b) => { SetSelectRow(rowControl, b); };
row.RowCustomEvent += (a, b) => { if (RowCustomEvent != null) { RowCustomEvent(a, b); } }; row.RowCustomEvent += (a, b) => { if (RowCustomEvent != null) { RowCustomEvent(a, b); } };
row.SourceChanged += RowSourceChanged; row.SourceChanged += RowSourceChanged;
......
...@@ -51,36 +51,6 @@ namespace HZH_Controls.Forms ...@@ -51,36 +51,6 @@ namespace HZH_Controls.Forms
m_size = childControl.Size; m_size = childControl.Size;
m_deviation = deviation; m_deviation = deviation;
//Point p = parentControl.Parent.PointToScreen(parentControl.Location);
//int intX = 0;
//int intY = 0;
//if (p.Y + parentControl.Height + childControl.Height > Screen.PrimaryScreen.Bounds.Height)
//{
// intY = p.Y - childControl.Height - 1;
// blnDown = false;
//}
//else
//{
// intY = p.Y + parentControl.Height + 1;
// blnDown = true;
//}
//if (p.X + childControl.Width > Screen.PrimaryScreen.Bounds.Width)
//{
// intX = Screen.PrimaryScreen.Bounds.Width - childControl.Width;
//}
//else
//{
// intX = p.X;
//}
//if (deviation.HasValue)
//{
// intX += deviation.Value.X;
// intY += deviation.Value.Y;
//}
//this.Location = new Point(intX, intY);
if (parentControl.FindForm() != null) if (parentControl.FindForm() != null)
{ {
Form frmP = parentControl.FindForm(); Form frmP = parentControl.FindForm();
...@@ -123,37 +93,37 @@ namespace HZH_Controls.Forms ...@@ -123,37 +93,37 @@ namespace HZH_Controls.Forms
#region 无焦点窗体 #region 无焦点窗体
[System.Runtime.InteropServices.DllImport("user32.dll")] //[System.Runtime.InteropServices.DllImport("user32.dll")]
private extern static IntPtr SetActiveWindow(IntPtr handle); //private extern static IntPtr SetActiveWindow(IntPtr handle);
private const int WM_ACTIVATE = 0x006; //private const int WM_ACTIVATE = 0x006;
private const int WM_ACTIVATEAPP = 0x01C; //private const int WM_ACTIVATEAPP = 0x01C;
private const int WM_NCACTIVATE = 0x086; //private const int WM_NCACTIVATE = 0x086;
private const int WA_INACTIVE = 0; //private const int WA_INACTIVE = 0;
private const int WM_MOUSEACTIVATE = 0x21; //private const int WM_MOUSEACTIVATE = 0x21;
private const int MA_NOACTIVATE = 3; //private const int MA_NOACTIVATE = 3;
protected override void WndProc(ref Message m) //protected override void WndProc(ref Message m)
{ //{
if (m.Msg == WM_MOUSEACTIVATE) // if (m.Msg == WM_MOUSEACTIVATE)
{ // {
m.Result = new IntPtr(MA_NOACTIVATE); // m.Result = new IntPtr(MA_NOACTIVATE);
return; // return;
} // }
else if (m.Msg == WM_NCACTIVATE) // else if (m.Msg == WM_NCACTIVATE)
{ // {
if (((int)m.WParam & 0xFFFF) != WA_INACTIVE) // if (((int)m.WParam & 0xFFFF) != WA_INACTIVE)
{ // {
if (m.LParam != IntPtr.Zero) // if (m.LParam != IntPtr.Zero)
{ // {
SetActiveWindow(m.LParam); // SetActiveWindow(m.LParam);
} // }
else // else
{ // {
SetActiveWindow(IntPtr.Zero); // SetActiveWindow(IntPtr.Zero);
} // }
} // }
} // }
base.WndProc(ref m); // base.WndProc(ref m);
} //}
#endregion #endregion
...@@ -215,12 +185,14 @@ namespace HZH_Controls.Forms ...@@ -215,12 +185,14 @@ namespace HZH_Controls.Forms
{ {
Form frm = this.Owner as Form; Form frm = this.Owner as Form;
IntPtr _ptr = ControlHelper.GetForegroundWindow(); IntPtr _ptr = ControlHelper.GetForegroundWindow();
if (_ptr != frm.Handle) if (_ptr != frm.Handle && _ptr!=this.Handle)
{ {
this.Hide(); this.Hide();
} }
} }
} }
} }
} }
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
this.btnClose.BackgroundImage = global::HZH_Controls.Properties.Resources.dialog_close; this.btnClose.BackgroundImage = global::HZH_Controls.Properties.Resources.dialog_close;
this.btnClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; this.btnClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.btnClose.Location = new System.Drawing.Point(399, 0); this.btnClose.Location = new System.Drawing.Point(399, 0);
this.btnClose.MaximumSize = new System.Drawing.Size(0, 60);
this.btnClose.Name = "btnClose"; this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(28, 60); this.btnClose.Size = new System.Drawing.Size(28, 60);
this.btnClose.TabIndex = 6; this.btnClose.TabIndex = 6;
......
...@@ -54,6 +54,18 @@ ...@@ -54,6 +54,18 @@
<Compile Include="Controls\Btn\UCDropDownBtn.Designer.cs"> <Compile Include="Controls\Btn\UCDropDownBtn.Designer.cs">
<DependentUpon>UCDropDownBtn.cs</DependentUpon> <DependentUpon>UCDropDownBtn.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\ComboBox\UCComboxGrid.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\ComboBox\UCComboxGrid.Designer.cs">
<DependentUpon>UCComboxGrid.cs</DependentUpon>
</Compile>
<Compile Include="Controls\ComboBox\UCComboxGridPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\ComboBox\UCComboxGridPanel.Designer.cs">
<DependentUpon>UCComboxGridPanel.cs</DependentUpon>
</Compile>
<Compile Include="Controls\DataGridView\DataGridViewCellEntity.cs" /> <Compile Include="Controls\DataGridView\DataGridViewCellEntity.cs" />
<Compile Include="Controls\DataGridView\DataGridViewCellEventArgs.cs" /> <Compile Include="Controls\DataGridView\DataGridViewCellEventArgs.cs" />
<Compile Include="Controls\DataGridView\DataGridViewCellEventHandler.cs" /> <Compile Include="Controls\DataGridView\DataGridViewCellEventHandler.cs" />
...@@ -204,11 +216,11 @@ ...@@ -204,11 +216,11 @@
<Compile Include="Controls\Checkbox\UCCheckBox.Designer.cs"> <Compile Include="Controls\Checkbox\UCCheckBox.Designer.cs">
<DependentUpon>UCCheckBox.cs</DependentUpon> <DependentUpon>UCCheckBox.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\ComboBox\UCComboBox.cs"> <Compile Include="Controls\ComboBox\UCCombox.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Controls\ComboBox\UCComboBox.Designer.cs"> <Compile Include="Controls\ComboBox\UCCombox.Designer.cs">
<DependentUpon>UCComboBox.cs</DependentUpon> <DependentUpon>UCCombox.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\DateTime\DateTimePickerType.cs" /> <Compile Include="Controls\DateTime\DateTimePickerType.cs" />
<Compile Include="Controls\DateTime\UCDatePickerExt.cs"> <Compile Include="Controls\DateTime\UCDatePickerExt.cs">
...@@ -426,8 +438,14 @@ ...@@ -426,8 +438,14 @@
<EmbeddedResource Include="Controls\Checkbox\UCCheckBox.resx"> <EmbeddedResource Include="Controls\Checkbox\UCCheckBox.resx">
<DependentUpon>UCCheckBox.cs</DependentUpon> <DependentUpon>UCCheckBox.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Controls\ComboBox\UCComboBox.resx"> <EmbeddedResource Include="Controls\ComboBox\UCCombox.resx">
<DependentUpon>UCComboBox.cs</DependentUpon> <DependentUpon>UCCombox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\ComboBox\UCComboxGrid.resx">
<DependentUpon>UCComboxGrid.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\ComboBox\UCComboxGridPanel.resx">
<DependentUpon>UCComboxGridPanel.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Controls\DataGridView\UCDataGridView.resx"> <EmbeddedResource Include="Controls\DataGridView\UCDataGridView.resx">
<DependentUpon>UCDataGridView.cs</DependentUpon> <DependentUpon>UCDataGridView.cs</DependentUpon>
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
this.button7 = new System.Windows.Forms.Button(); this.button7 = new System.Windows.Forms.Button();
this.button8 = new System.Windows.Forms.Button(); this.button8 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.ucComboxGrid1 = new HZH_Controls.Controls.ComboBox.UCComboxGrid();
this.groupBox9 = new System.Windows.Forms.GroupBox(); this.groupBox9 = new System.Windows.Forms.GroupBox();
this.ucHorizontalList1 = new HZH_Controls.Controls.UCHorizontalList(); this.ucHorizontalList1 = new HZH_Controls.Controls.UCHorizontalList();
this.groupBox7 = new System.Windows.Forms.GroupBox(); this.groupBox7 = new System.Windows.Forms.GroupBox();
...@@ -47,8 +48,8 @@ ...@@ -47,8 +48,8 @@
this.ucDatePickerExt2 = new HZH_Controls.Controls.UCDatePickerExt(); this.ucDatePickerExt2 = new HZH_Controls.Controls.UCDatePickerExt();
this.ucDatePickerExt1 = new HZH_Controls.Controls.UCDatePickerExt(); this.ucDatePickerExt1 = new HZH_Controls.Controls.UCDatePickerExt();
this.groupBox6 = new System.Windows.Forms.GroupBox(); this.groupBox6 = new System.Windows.Forms.GroupBox();
this.ucComboBox2 = new HZH_Controls.Controls.UCComboBox(); this.ucComboBox2 = new HZH_Controls.Controls.UCCombox();
this.ucComboBox1 = new HZH_Controls.Controls.UCComboBox(); this.ucComboBox1 = new HZH_Controls.Controls.UCCombox();
this.groupBox8 = new System.Windows.Forms.GroupBox(); this.groupBox8 = new System.Windows.Forms.GroupBox();
this.ucListExt1 = new HZH_Controls.Controls.UCListExt(); this.ucListExt1 = new HZH_Controls.Controls.UCListExt();
this.groupBox5 = new System.Windows.Forms.GroupBox(); this.groupBox5 = new System.Windows.Forms.GroupBox();
...@@ -194,6 +195,7 @@ ...@@ -194,6 +195,7 @@
// //
// groupBox1 // groupBox1
// //
this.groupBox1.Controls.Add(this.ucComboxGrid1);
this.groupBox1.Controls.Add(this.groupBox9); this.groupBox1.Controls.Add(this.groupBox9);
this.groupBox1.Controls.Add(this.groupBox7); this.groupBox1.Controls.Add(this.groupBox7);
this.groupBox1.Controls.Add(this.groupBox6); this.groupBox1.Controls.Add(this.groupBox6);
...@@ -209,6 +211,35 @@ ...@@ -209,6 +211,35 @@
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "控件"; this.groupBox1.Text = "控件";
// //
// ucComboxGrid1
//
this.ucComboxGrid1.BackColor = System.Drawing.Color.Transparent;
this.ucComboxGrid1.BackColorExt = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.ucComboxGrid1.BoxStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ucComboxGrid1.ConerRadius = 5;
this.ucComboxGrid1.DropPanelHeight = -1;
this.ucComboxGrid1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.ucComboxGrid1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.ucComboxGrid1.GridColumns = null;
this.ucComboxGrid1.GridDataSource = null;
this.ucComboxGrid1.GridRowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucComboxGrid1.IsRadius = false;
this.ucComboxGrid1.IsShowRect = true;
this.ucComboxGrid1.ItemWidth = 70;
this.ucComboxGrid1.Location = new System.Drawing.Point(233, 490);
this.ucComboxGrid1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ucComboxGrid1.Name = "ucComboxGrid1";
this.ucComboxGrid1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.ucComboxGrid1.RectWidth = 1;
this.ucComboxGrid1.SelectedIndex = -1;
this.ucComboxGrid1.SelectedValue = "";
this.ucComboxGrid1.SelectSource = null;
this.ucComboxGrid1.Size = new System.Drawing.Size(173, 32);
this.ucComboxGrid1.Source = null;
this.ucComboxGrid1.TabIndex = 9;
this.ucComboxGrid1.TextField = "Name";
this.ucComboxGrid1.TextValue = null;
//
// groupBox9 // groupBox9
// //
this.groupBox9.Controls.Add(this.ucHorizontalList1); this.groupBox9.Controls.Add(this.ucHorizontalList1);
...@@ -1214,8 +1245,8 @@ ...@@ -1214,8 +1245,8 @@
private HZH_Controls.Controls.UCBtnFillet ucBtnFillet1; private HZH_Controls.Controls.UCBtnFillet ucBtnFillet1;
private HZH_Controls.Controls.UCBtnExt ucBtnExt2; private HZH_Controls.Controls.UCBtnExt ucBtnExt2;
private System.Windows.Forms.GroupBox groupBox6; private System.Windows.Forms.GroupBox groupBox6;
private HZH_Controls.Controls.UCComboBox ucComboBox2; private HZH_Controls.Controls.UCCombox ucComboBox2;
private HZH_Controls.Controls.UCComboBox ucComboBox1; private HZH_Controls.Controls.UCCombox ucComboBox1;
private System.Windows.Forms.GroupBox groupBox5; private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.GroupBox groupBox7; private System.Windows.Forms.GroupBox groupBox7;
private HZH_Controls.Controls.UCDatePickerExt ucDatePickerExt3; private HZH_Controls.Controls.UCDatePickerExt ucDatePickerExt3;
...@@ -1242,6 +1273,7 @@ ...@@ -1242,6 +1273,7 @@
private HZH_Controls.Controls.UCBtnExt ucBtnExt4; private HZH_Controls.Controls.UCBtnExt ucBtnExt4;
private HZH_Controls.Controls.UCBtnExt ucBtnExt5; private HZH_Controls.Controls.UCBtnExt ucBtnExt5;
private HZH_Controls.Controls.Btn.UCDropDownBtn ucDropDownBtn1; private HZH_Controls.Controls.Btn.UCDropDownBtn ucDropDownBtn1;
private HZH_Controls.Controls.ComboBox.UCComboxGrid ucComboxGrid1;
} }
} }
...@@ -114,7 +114,29 @@ namespace Test ...@@ -114,7 +114,29 @@ namespace Test
ucBtnsGroup2.DataSource = new Dictionary<string, string>() { { "1", "河南" }, { "2", "北京" }, { "3", "湖南" }, { "4", "上海" } }; ucBtnsGroup2.DataSource = new Dictionary<string, string>() { { "1", "河南" }, { "2", "北京" }, { "3", "湖南" }, { "4", "上海" } };
ucBtnsGroup2.SelectItem = new List<string>() { "2", "3" }; ucBtnsGroup2.SelectItem = new List<string>() { "2", "3" };
List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "ID", HeadText = "编号", Width = 70, WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Name", HeadText = "姓名", Width = 100, WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Age", HeadText = "年龄", Width = 100, WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Birthday", HeadText = "生日", Width = 120, WidthType = SizeType.Absolute, Format = (a) => { return ((DateTime)a).ToString("yyyy-MM-dd"); } });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Sex", HeadText = "性别", Width = 100, WidthType = SizeType.Absolute, Format = (a) => { return ((int)a) == 0 ? "女" : "男"; } });
this.ucComboxGrid1.GridColumns = lstCulumns;
List<object> lstSourceGrid = new List<object>();
for (int i = 0; i < 100; i++)
{
TestModel model = new TestModel()
{
ID = i.ToString(),
Age = 3 * i,
Name = "姓名——" + i,
Birthday = DateTime.Now.AddYears(-10),
Sex = i % 2
};
lstSourceGrid.Add(model);
}
this.ucComboxGrid1.GridDataSource = lstSourceGrid;
} }
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
......
...@@ -31,7 +31,7 @@ namespace Test ...@@ -31,7 +31,7 @@ namespace Test
this.ucDataGridView1.Columns = lstCulumns; this.ucDataGridView1.Columns = lstCulumns;
this.ucDataGridView1.IsShowCheckBox = true; this.ucDataGridView1.IsShowCheckBox = true;
List<object> lstSource = new List<object>(); List<object> lstSource = new List<object>();
for (int i = 0; i < 200; i++) for (int i = 0; i < 50; i++)
{ {
TestModel model = new TestModel() TestModel model = new TestModel()
{ {
...@@ -42,13 +42,15 @@ namespace Test ...@@ -42,13 +42,15 @@ namespace Test
Sex = i % 2 Sex = i % 2
}; };
lstSource.Add(model); lstSource.Add(model);
AddChilds(model, 5); //AddChilds(model, 5);
} }
var page = new UCPagerControl2(); var page = new UCPagerControl2();
page.DataSource = lstSource; page.DataSource = lstSource;
this.ucDataGridView1.Page = page; this.ucDataGridView1.Page = page;
this.ucDataGridView1.First(); this.ucDataGridView1.First();
//this.ucDataGridView1.DataSource = lstSource;
} }
private void AddChilds(TestModel tm, int intCount) private void AddChilds(TestModel tm, int intCount)
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(427, 310); this.ClientSize = new System.Drawing.Size(427, 310);
this.IsShowCloseBtn = true;
this.Name = "FrmWithTitleTest"; this.Name = "FrmWithTitleTest";
this.Text = "FrmWithTitleTest"; this.Text = "FrmWithTitleTest";
this.Title = "单标题窗体测试"; this.Title = "单标题窗体测试";
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!