Commit 35ef5cf9 HZH

add comboxgrid

1 个父辈 cd36457d
namespace HZH_Controls.Controls
{
partial class UCComboBox
partial class UCCombox
{
/// <summary>
/// 必需的设计器变量。
......@@ -53,7 +53,7 @@
this.txtInput.DecLength = 2;
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.InputType = TextInputType.NotControl;
this.txtInput.InputType = HZH_Controls.TextInputType.NotControl;
this.txtInput.Location = new System.Drawing.Point(3, 4);
this.txtInput.Margin = new System.Windows.Forms.Padding(3, 3, 10, 3);
this.txtInput.MaxValue = new decimal(new int[] {
......@@ -88,7 +88,7 @@
this.lblInput.Visible = false;
this.lblInput.MouseDown += new System.Windows.Forms.MouseEventHandler(this.click_MouseDown);
//
// UCComboBox
// UCCombox
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.Transparent;
......@@ -96,9 +96,9 @@
this.Controls.Add(this.panel1);
this.Controls.Add(this.txtInput);
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.Name = "UCComboBox";
this.Name = "UCCombox";
this.Size = new System.Drawing.Size(173, 32);
this.Load += new System.EventHandler(this.UCComboBox_Load);
this.SizeChanged += new System.EventHandler(this.UCComboBox_SizeChanged);
......
......@@ -15,7 +15,7 @@ using System.Windows.Forms;
namespace HZH_Controls.Controls
{
[DefaultEvent("SelectedChangedEvent")]
public partial class UCComboBox : UCControlBase
public partial class UCCombox : UCControlBase
{
Color _ForeColor = Color.FromArgb(64, 64, 64);
[Description("文字颜色"), Category("自定义")]
......@@ -279,7 +279,7 @@ namespace HZH_Controls.Controls
}
}
public UCComboBox()
public UCCombox()
{
InitializeComponent();
lblInput.BackColor = _BackColor;
......@@ -313,7 +313,7 @@ namespace HZH_Controls.Controls
}
}
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)
{
......
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
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
......@@ -81,7 +81,6 @@
//
// panRow
//
this.panRow.AutoScroll = true;
this.panRow.Dock = System.Windows.Forms.DockStyle.Fill;
this.panRow.Location = new System.Drawing.Point(0, 40);
this.panRow.Name = "panRow";
......
......@@ -167,9 +167,11 @@ namespace HZH_Controls.Controls
}
m_dataSource = value;
if (m_columns != null && m_columns.Count > 0)
{
ReloadSource();
}
}
}
public List<IDataGridViewRow> Rows { get; private set; }
......@@ -222,18 +224,23 @@ namespace HZH_Controls.Controls
List<IDataGridViewRow> lst = new List<IDataGridViewRow>();
if (m_isShowCheckBox)
{
if (Rows != null && Rows.Count > 0)
lst.AddRange(Rows.FindAll(p => p.IsChecked));
}
else
{
if (m_selectRow != null)
lst.AddRange(new List<IDataGridViewRow>() { m_selectRow });
}
if (Rows != null && Rows.Count > 0)
{
foreach (var row in Rows)
{
Control c = row as Control;
UCDataGridView grid = FindChildGrid(c);
lst.AddRange(grid.SelectRows);
}
}
return lst;
}
......@@ -271,6 +278,7 @@ namespace HZH_Controls.Controls
panPage.Visible = value != null;
m_page.ShowSourceChanged += page_ShowSourceChanged;
m_page.Dock = DockStyle.Fill;
//this.panPage.Height = value.Height;
this.panPage.Controls.Clear();
this.panPage.Controls.Add(m_page);
ResetShowCount();
......@@ -292,7 +300,11 @@ namespace HZH_Controls.Controls
public bool IsAutoHeight
{
get { return m_isAutoHeight; }
set { m_isAutoHeight = value; }
set
{
m_isAutoHeight = value;
this.AutoScroll = value;
}
}
void page_ShowSourceChanged(object currentSource)
......@@ -432,7 +444,6 @@ namespace HZH_Controls.Controls
ControlHelper.FreezeControl(this.panRow, true);
this.panRow.Controls.Clear();
Rows = new List<IDataGridViewRow>();
if (m_columns == null || m_columns.Count <= 0)
return;
......@@ -505,7 +516,7 @@ namespace HZH_Controls.Controls
this.panRow.Controls.Add(rowControl);
row.RowHeight = m_rowHeight;
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.RowCustomEvent += (a, b) => { if (RowCustomEvent != null) { RowCustomEvent(a, b); } };
row.SourceChanged += RowSourceChanged;
......
......@@ -51,36 +51,6 @@ namespace HZH_Controls.Forms
m_size = childControl.Size;
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)
{
Form frmP = parentControl.FindForm();
......@@ -123,37 +93,37 @@ namespace HZH_Controls.Forms
#region 无焦点窗体
[System.Runtime.InteropServices.DllImport("user32.dll")]
private extern static IntPtr SetActiveWindow(IntPtr handle);
private const int WM_ACTIVATE = 0x006;
private const int WM_ACTIVATEAPP = 0x01C;
private const int WM_NCACTIVATE = 0x086;
private const int WA_INACTIVE = 0;
private const int WM_MOUSEACTIVATE = 0x21;
private const int MA_NOACTIVATE = 3;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_MOUSEACTIVATE)
{
m.Result = new IntPtr(MA_NOACTIVATE);
return;
}
else if (m.Msg == WM_NCACTIVATE)
{
if (((int)m.WParam & 0xFFFF) != WA_INACTIVE)
{
if (m.LParam != IntPtr.Zero)
{
SetActiveWindow(m.LParam);
}
else
{
SetActiveWindow(IntPtr.Zero);
}
}
}
base.WndProc(ref m);
}
//[System.Runtime.InteropServices.DllImport("user32.dll")]
//private extern static IntPtr SetActiveWindow(IntPtr handle);
//private const int WM_ACTIVATE = 0x006;
//private const int WM_ACTIVATEAPP = 0x01C;
//private const int WM_NCACTIVATE = 0x086;
//private const int WA_INACTIVE = 0;
//private const int WM_MOUSEACTIVATE = 0x21;
//private const int MA_NOACTIVATE = 3;
//protected override void WndProc(ref Message m)
//{
// if (m.Msg == WM_MOUSEACTIVATE)
// {
// m.Result = new IntPtr(MA_NOACTIVATE);
// return;
// }
// else if (m.Msg == WM_NCACTIVATE)
// {
// if (((int)m.WParam & 0xFFFF) != WA_INACTIVE)
// {
// if (m.LParam != IntPtr.Zero)
// {
// SetActiveWindow(m.LParam);
// }
// else
// {
// SetActiveWindow(IntPtr.Zero);
// }
// }
// }
// base.WndProc(ref m);
//}
#endregion
......@@ -215,12 +185,14 @@ namespace HZH_Controls.Forms
{
Form frm = this.Owner as Form;
IntPtr _ptr = ControlHelper.GetForegroundWindow();
if (_ptr != frm.Handle)
if (_ptr != frm.Handle && _ptr!=this.Handle)
{
this.Hide();
}
}
}
}
}
......@@ -62,7 +62,6 @@
this.btnClose.BackgroundImage = global::HZH_Controls.Properties.Resources.dialog_close;
this.btnClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.btnClose.Location = new System.Drawing.Point(399, 0);
this.btnClose.MaximumSize = new System.Drawing.Size(0, 60);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(28, 60);
this.btnClose.TabIndex = 6;
......
......@@ -54,6 +54,18 @@
<Compile Include="Controls\Btn\UCDropDownBtn.Designer.cs">
<DependentUpon>UCDropDownBtn.cs</DependentUpon>
</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\DataGridViewCellEventArgs.cs" />
<Compile Include="Controls\DataGridView\DataGridViewCellEventHandler.cs" />
......@@ -204,11 +216,11 @@
<Compile Include="Controls\Checkbox\UCCheckBox.Designer.cs">
<DependentUpon>UCCheckBox.cs</DependentUpon>
</Compile>
<Compile Include="Controls\ComboBox\UCComboBox.cs">
<Compile Include="Controls\ComboBox\UCCombox.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\ComboBox\UCComboBox.Designer.cs">
<DependentUpon>UCComboBox.cs</DependentUpon>
<Compile Include="Controls\ComboBox\UCCombox.Designer.cs">
<DependentUpon>UCCombox.cs</DependentUpon>
</Compile>
<Compile Include="Controls\DateTime\DateTimePickerType.cs" />
<Compile Include="Controls\DateTime\UCDatePickerExt.cs">
......@@ -426,8 +438,14 @@
<EmbeddedResource Include="Controls\Checkbox\UCCheckBox.resx">
<DependentUpon>UCCheckBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\ComboBox\UCComboBox.resx">
<DependentUpon>UCComboBox.cs</DependentUpon>
<EmbeddedResource Include="Controls\ComboBox\UCCombox.resx">
<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 Include="Controls\DataGridView\UCDataGridView.resx">
<DependentUpon>UCDataGridView.cs</DependentUpon>
......
......@@ -40,6 +40,7 @@
this.button7 = new System.Windows.Forms.Button();
this.button8 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.ucComboxGrid1 = new HZH_Controls.Controls.ComboBox.UCComboxGrid();
this.groupBox9 = new System.Windows.Forms.GroupBox();
this.ucHorizontalList1 = new HZH_Controls.Controls.UCHorizontalList();
this.groupBox7 = new System.Windows.Forms.GroupBox();
......@@ -47,8 +48,8 @@
this.ucDatePickerExt2 = new HZH_Controls.Controls.UCDatePickerExt();
this.ucDatePickerExt1 = new HZH_Controls.Controls.UCDatePickerExt();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.ucComboBox2 = new HZH_Controls.Controls.UCComboBox();
this.ucComboBox1 = new HZH_Controls.Controls.UCComboBox();
this.ucComboBox2 = new HZH_Controls.Controls.UCCombox();
this.ucComboBox1 = new HZH_Controls.Controls.UCCombox();
this.groupBox8 = new System.Windows.Forms.GroupBox();
this.ucListExt1 = new HZH_Controls.Controls.UCListExt();
this.groupBox5 = new System.Windows.Forms.GroupBox();
......@@ -194,6 +195,7 @@
//
// groupBox1
//
this.groupBox1.Controls.Add(this.ucComboxGrid1);
this.groupBox1.Controls.Add(this.groupBox9);
this.groupBox1.Controls.Add(this.groupBox7);
this.groupBox1.Controls.Add(this.groupBox6);
......@@ -209,6 +211,35 @@
this.groupBox1.TabStop = false;
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
//
this.groupBox9.Controls.Add(this.ucHorizontalList1);
......@@ -1214,8 +1245,8 @@
private HZH_Controls.Controls.UCBtnFillet ucBtnFillet1;
private HZH_Controls.Controls.UCBtnExt ucBtnExt2;
private System.Windows.Forms.GroupBox groupBox6;
private HZH_Controls.Controls.UCComboBox ucComboBox2;
private HZH_Controls.Controls.UCComboBox ucComboBox1;
private HZH_Controls.Controls.UCCombox ucComboBox2;
private HZH_Controls.Controls.UCCombox ucComboBox1;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.GroupBox groupBox7;
private HZH_Controls.Controls.UCDatePickerExt ucDatePickerExt3;
......@@ -1242,6 +1273,7 @@
private HZH_Controls.Controls.UCBtnExt ucBtnExt4;
private HZH_Controls.Controls.UCBtnExt ucBtnExt5;
private HZH_Controls.Controls.Btn.UCDropDownBtn ucDropDownBtn1;
private HZH_Controls.Controls.ComboBox.UCComboxGrid ucComboxGrid1;
}
}
......@@ -115,6 +115,28 @@ namespace Test
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)
......
......@@ -31,7 +31,7 @@ namespace Test
this.ucDataGridView1.Columns = lstCulumns;
this.ucDataGridView1.IsShowCheckBox = true;
List<object> lstSource = new List<object>();
for (int i = 0; i < 200; i++)
for (int i = 0; i < 50; i++)
{
TestModel model = new TestModel()
{
......@@ -42,13 +42,15 @@ namespace Test
Sex = i % 2
};
lstSource.Add(model);
AddChilds(model, 5);
//AddChilds(model, 5);
}
var page = new UCPagerControl2();
page.DataSource = lstSource;
this.ucDataGridView1.Page = page;
this.ucDataGridView1.First();
//this.ucDataGridView1.DataSource = lstSource;
}
private void AddChilds(TestModel tm, int intCount)
......
......@@ -35,6 +35,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(427, 310);
this.IsShowCloseBtn = true;
this.Name = "FrmWithTitleTest";
this.Text = "FrmWithTitleTest";
this.Title = "单标题窗体测试";
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!