* UIComboDataGridView: 过滤输入后,按键盘下键切换至DataGridView,选中数据后按回车可快捷选中数据

This commit is contained in:
Sunny 2023-07-25 22:56:23 +08:00
parent 436a34fd6b
commit 7082bfc013
3 changed files with 253 additions and 182 deletions

View File

@ -53,7 +53,7 @@ namespace Sunny.UI
public bool TrimFilter { get; set; }
private void EdtFilter_TextChanged(object sender, System.EventArgs e)
private void EdtFilter_TextChanged(object sender, EventArgs e)
{
if (!Filter1by1) return;
btnSearch_Click(null, null);
@ -99,215 +99,210 @@ namespace Sunny.UI
private void InitializeComponent()
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
this.panel = new Sunny.UI.UIPanel();
this.btnCancel = new Sunny.UI.UISymbolButton();
this.btnOK = new Sunny.UI.UISymbolButton();
this.dataGridView = new Sunny.UI.UIDataGridView();
this.pFilter = new Sunny.UI.UIPanel();
this.btnClear = new Sunny.UI.UISymbolButton();
this.btnSearch = new Sunny.UI.UISymbolButton();
this.edtFilter = new Sunny.UI.UITextBox();
this.panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.pFilter.SuspendLayout();
this.SuspendLayout();
DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle4 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle5 = new DataGridViewCellStyle();
panel = new UIPanel();
btnCancel = new UISymbolButton();
btnOK = new UISymbolButton();
dataGridView = new UIDataGridView();
pFilter = new UIPanel();
btnClear = new UISymbolButton();
btnSearch = new UISymbolButton();
edtFilter = new UITextBox();
panel.SuspendLayout();
((ISupportInitialize)dataGridView).BeginInit();
pFilter.SuspendLayout();
SuspendLayout();
//
// panel
//
this.panel.Controls.Add(this.btnCancel);
this.panel.Controls.Add(this.btnOK);
this.panel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.panel.Location = new System.Drawing.Point(0, 289);
this.panel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.panel.MinimumSize = new System.Drawing.Size(1, 1);
this.panel.Name = "panel";
this.panel.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.panel.RectSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)(((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)
| System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom)));
this.panel.Size = new System.Drawing.Size(569, 44);
this.panel.TabIndex = 2;
this.panel.Text = null;
this.panel.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.panel.Visible = false;
this.panel.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
panel.Controls.Add(btnCancel);
panel.Controls.Add(btnOK);
panel.Dock = DockStyle.Bottom;
panel.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
panel.Location = new System.Drawing.Point(0, 289);
panel.Margin = new Padding(4, 5, 4, 5);
panel.MinimumSize = new System.Drawing.Size(1, 1);
panel.Name = "panel";
panel.RadiusSides = UICornerRadiusSides.None;
panel.RectSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Right | ToolStripStatusLabelBorderSides.Bottom;
panel.Size = new System.Drawing.Size(569, 44);
panel.TabIndex = 2;
panel.Text = null;
panel.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
panel.Visible = false;
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnCancel.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.btnCancel.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.btnCancel.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(115)))), ((int)(((byte)(115)))));
this.btnCancel.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.btnCancel.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.btnCancel.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.btnCancel.Location = new System.Drawing.Point(478, 8);
this.btnCancel.MinimumSize = new System.Drawing.Size(1, 1);
this.btnCancel.Name = "btnCancel";
this.btnCancel.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.btnCancel.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(115)))), ((int)(((byte)(115)))));
this.btnCancel.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.btnCancel.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.btnCancel.Size = new System.Drawing.Size(80, 29);
this.btnCancel.Style = Sunny.UI.UIStyle.Red;
this.btnCancel.StyleCustomMode = true;
this.btnCancel.Symbol = 61453;
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "取消";
this.btnCancel.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
btnCancel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
btnCancel.Cursor = Cursors.Hand;
btnCancel.FillColor = System.Drawing.Color.FromArgb(230, 80, 80);
btnCancel.FillColor2 = System.Drawing.Color.FromArgb(230, 80, 80);
btnCancel.FillHoverColor = System.Drawing.Color.FromArgb(235, 115, 115);
btnCancel.FillPressColor = System.Drawing.Color.FromArgb(184, 64, 64);
btnCancel.FillSelectedColor = System.Drawing.Color.FromArgb(184, 64, 64);
btnCancel.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnCancel.Location = new System.Drawing.Point(478, 8);
btnCancel.MinimumSize = new System.Drawing.Size(1, 1);
btnCancel.Name = "btnCancel";
btnCancel.RectColor = System.Drawing.Color.FromArgb(230, 80, 80);
btnCancel.RectHoverColor = System.Drawing.Color.FromArgb(235, 115, 115);
btnCancel.RectPressColor = System.Drawing.Color.FromArgb(184, 64, 64);
btnCancel.RectSelectedColor = System.Drawing.Color.FromArgb(184, 64, 64);
btnCancel.Size = new System.Drawing.Size(80, 29);
btnCancel.Style = UIStyle.Red;
btnCancel.StyleCustomMode = true;
btnCancel.Symbol = 61453;
btnCancel.TabIndex = 1;
btnCancel.Text = "取消";
btnCancel.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnCancel.Click += btnCancel_Click;
//
// btnOK
//
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnOK.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnOK.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.btnOK.Location = new System.Drawing.Point(389, 8);
this.btnOK.MinimumSize = new System.Drawing.Size(1, 1);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(80, 29);
this.btnOK.TabIndex = 0;
this.btnOK.Text = "确定";
this.btnOK.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
btnOK.Anchor = AnchorStyles.Top | AnchorStyles.Right;
btnOK.Cursor = Cursors.Hand;
btnOK.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnOK.Location = new System.Drawing.Point(389, 8);
btnOK.MinimumSize = new System.Drawing.Size(1, 1);
btnOK.Name = "btnOK";
btnOK.Size = new System.Drawing.Size(80, 29);
btnOK.TabIndex = 0;
btnOK.Text = "确定";
btnOK.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnOK.Click += btnOK_Click;
//
// dataGridView
//
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(249)))), ((int)(((byte)(255)))));
this.dataGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
this.dataGridView.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(249)))), ((int)(((byte)(255)))));
this.dataGridView.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(243, 249, 255);
dataGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
dataGridView.BackgroundColor = System.Drawing.Color.FromArgb(243, 249, 255);
dataGridView.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
dataGridViewCellStyle2.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(80, 160, 255);
dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
dataGridViewCellStyle2.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(80, 160, 255);
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.WrapMode = DataGridViewTriState.True;
dataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(236)))), ((int)(((byte)(255)))));
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridView.DefaultCellStyle = dataGridViewCellStyle3;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView.EnableHeadersVisualStyles = false;
this.dataGridView.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.dataGridView.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(173)))), ((int)(((byte)(255)))));
this.dataGridView.Location = new System.Drawing.Point(0, 44);
this.dataGridView.MultiSelect = false;
this.dataGridView.Name = "dataGridView";
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(249)))), ((int)(((byte)(255)))));
dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(220, 236, 255);
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle3.WrapMode = DataGridViewTriState.False;
dataGridView.DefaultCellStyle = dataGridViewCellStyle3;
dataGridView.Dock = DockStyle.Fill;
dataGridView.EnableHeadersVisualStyles = false;
dataGridView.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
dataGridView.GridColor = System.Drawing.Color.FromArgb(104, 173, 255);
dataGridView.Location = new System.Drawing.Point(0, 44);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridViewCellStyle4.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(243, 249, 255);
dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle4;
dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(80, 160, 255);
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle4.WrapMode = DataGridViewTriState.True;
dataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle4;
dataGridViewCellStyle5.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(236)))), ((int)(((byte)(255)))));
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.dataGridView.RowsDefaultCellStyle = dataGridViewCellStyle5;
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.ScrollBarRectColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.dataGridView.SelectedIndex = -1;
this.dataGridView.Size = new System.Drawing.Size(569, 245);
this.dataGridView.TabIndex = 3;
this.dataGridView.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(220, 236, 255);
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(48, 48, 48);
dataGridView.RowsDefaultCellStyle = dataGridViewCellStyle5;
dataGridView.RowTemplate.Height = 25;
dataGridView.ScrollBarRectColor = System.Drawing.Color.FromArgb(80, 160, 255);
dataGridView.SelectedIndex = -1;
dataGridView.Size = new System.Drawing.Size(569, 245);
dataGridView.TabIndex = 3;
dataGridView.KeyDown += dataGridView_KeyDown;
//
// pFilter
//
this.pFilter.Controls.Add(this.btnClear);
this.pFilter.Controls.Add(this.btnSearch);
this.pFilter.Controls.Add(this.edtFilter);
this.pFilter.Dock = System.Windows.Forms.DockStyle.Top;
this.pFilter.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.pFilter.Location = new System.Drawing.Point(0, 0);
this.pFilter.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.pFilter.MinimumSize = new System.Drawing.Size(1, 1);
this.pFilter.Name = "pFilter";
this.pFilter.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.pFilter.RectSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)(((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top)
| System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
this.pFilter.Size = new System.Drawing.Size(569, 44);
this.pFilter.TabIndex = 4;
this.pFilter.Text = null;
this.pFilter.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.pFilter.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
pFilter.Controls.Add(btnClear);
pFilter.Controls.Add(btnSearch);
pFilter.Controls.Add(edtFilter);
pFilter.Dock = DockStyle.Top;
pFilter.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
pFilter.Location = new System.Drawing.Point(0, 0);
pFilter.Margin = new Padding(4, 5, 4, 5);
pFilter.MinimumSize = new System.Drawing.Size(1, 1);
pFilter.Name = "pFilter";
pFilter.RadiusSides = UICornerRadiusSides.None;
pFilter.RectSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Right;
pFilter.Size = new System.Drawing.Size(569, 44);
pFilter.TabIndex = 4;
pFilter.Text = null;
pFilter.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
//
// btnClear
//
this.btnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnClear.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnClear.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.btnClear.Location = new System.Drawing.Point(478, 8);
this.btnClear.MinimumSize = new System.Drawing.Size(1, 1);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(80, 29);
this.btnClear.Symbol = 61666;
this.btnClear.SymbolSize = 22;
this.btnClear.TabIndex = 2;
this.btnClear.Text = "清除";
this.btnClear.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
btnClear.Anchor = AnchorStyles.Top | AnchorStyles.Right;
btnClear.Cursor = Cursors.Hand;
btnClear.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnClear.Location = new System.Drawing.Point(478, 8);
btnClear.MinimumSize = new System.Drawing.Size(1, 1);
btnClear.Name = "btnClear";
btnClear.Size = new System.Drawing.Size(80, 29);
btnClear.Symbol = 61666;
btnClear.SymbolSize = 22;
btnClear.TabIndex = 2;
btnClear.Text = "清除";
btnClear.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnClear.Click += btnClear_Click;
//
// btnSearch
//
this.btnSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnSearch.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnSearch.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.btnSearch.Location = new System.Drawing.Point(389, 8);
this.btnSearch.MinimumSize = new System.Drawing.Size(1, 1);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(80, 29);
this.btnSearch.Symbol = 61442;
this.btnSearch.TabIndex = 1;
this.btnSearch.Text = "搜索";
this.btnSearch.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
btnSearch.Anchor = AnchorStyles.Top | AnchorStyles.Right;
btnSearch.Cursor = Cursors.Hand;
btnSearch.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnSearch.Location = new System.Drawing.Point(389, 8);
btnSearch.MinimumSize = new System.Drawing.Size(1, 1);
btnSearch.Name = "btnSearch";
btnSearch.Size = new System.Drawing.Size(80, 29);
btnSearch.Symbol = 61442;
btnSearch.TabIndex = 1;
btnSearch.Text = "搜索";
btnSearch.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
btnSearch.Click += btnSearch_Click;
//
// edtFilter
//
this.edtFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.edtFilter.Cursor = System.Windows.Forms.Cursors.IBeam;
this.edtFilter.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.edtFilter.Location = new System.Drawing.Point(17, 10);
this.edtFilter.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.edtFilter.MinimumSize = new System.Drawing.Size(1, 16);
this.edtFilter.Name = "edtFilter";
this.edtFilter.ShowText = false;
this.edtFilter.Size = new System.Drawing.Size(363, 25);
this.edtFilter.TabIndex = 0;
this.edtFilter.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
this.edtFilter.Watermark = "";
this.edtFilter.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.edtFilter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.edtFilter_KeyDown);
edtFilter.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
edtFilter.ButtonSymbolOffset = new System.Drawing.Point(0, 0);
edtFilter.Cursor = Cursors.IBeam;
edtFilter.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
edtFilter.Location = new System.Drawing.Point(17, 10);
edtFilter.Margin = new Padding(4, 5, 4, 5);
edtFilter.MinimumSize = new System.Drawing.Size(1, 16);
edtFilter.Name = "edtFilter";
edtFilter.Padding = new Padding(5);
edtFilter.ShowText = false;
edtFilter.Size = new System.Drawing.Size(363, 25);
edtFilter.TabIndex = 0;
edtFilter.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
edtFilter.Watermark = "";
edtFilter.KeyDown += edtFilter_KeyDown;
//
// UIComboDataGridViewItem
//
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.pFilter);
this.Controls.Add(this.panel);
this.Name = "UIComboDataGridViewItem";
this.Size = new System.Drawing.Size(569, 333);
this.panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.pFilter.ResumeLayout(false);
this.ResumeLayout(false);
Controls.Add(dataGridView);
Controls.Add(pFilter);
Controls.Add(panel);
Name = "UIComboDataGridViewItem";
Size = new System.Drawing.Size(569, 333);
panel.ResumeLayout(false);
((ISupportInitialize)dataGridView).EndInit();
pFilter.ResumeLayout(false);
ResumeLayout(false);
}
/// <summary>
@ -326,7 +321,7 @@ namespace Sunny.UI
btnClear.SetStyleColor(uiColor.DropDownStyle);
}
private void DataGridView_DataSourceChanged(object sender, System.EventArgs e)
private void DataGridView_DataSourceChanged(object sender, EventArgs e)
{
if (dataGridView.RowCount > 0)
{
@ -338,7 +333,7 @@ namespace Sunny.UI
}
}
private void btnOK_Click(object sender, System.EventArgs e)
private void btnOK_Click(object sender, EventArgs e)
{
//UIMessageTip.ShowOk(dataGridView.SelectedIndex.ToString(), 3000);
//UConsole.WriteConsole("所选行:"+dataGridView.SelectedIndex.ToString(),e,sender);
@ -360,7 +355,7 @@ namespace Sunny.UI
Close();
}
private void btnCancel_Click(object sender, System.EventArgs e)
private void btnCancel_Click(object sender, EventArgs e)
{
Close();
}
@ -371,7 +366,7 @@ namespace Sunny.UI
set => pFilter.Visible = value;
}
private void btnSearch_Click(object sender, System.EventArgs e)
private void btnSearch_Click(object sender, EventArgs e)
{
string filter = "";
string filterText = edtFilter.Text;
@ -420,7 +415,7 @@ namespace Sunny.UI
ComboDataGridViewFilterChanged?.Invoke(this, new UIComboDataGridViewArgs(filterText, dataGridView.RowCount));
}
private void btnClear_Click(object sender, System.EventArgs e)
private void btnClear_Click(object sender, EventArgs e)
{
edtFilter.Text = "";
btnSearch.PerformClick();
@ -445,7 +440,22 @@ namespace Sunny.UI
private void edtFilter_KeyDown(object sender, KeyEventArgs e)
{
if (!Filter1by1 && e.KeyData == Keys.Enter)
{
btnSearch_Click(null, null);
}
if (e.KeyData == Keys.Down)
{
dataGridView.Focus();
}
}
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
DataGridView_CellDoubleClick(this, null);
}
}
}
}

View File

@ -1,4 +1,64 @@
<root>
<?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">

View File

@ -27,6 +27,7 @@
* 2022-11-18: V3.2.9 Filter1by1
* 2022-11-18: V3.2.9
* 2022-11-30: V3.3.0 Clear方法
* 2023-07-25: V3.4.1 DataGridView
******************************************************************************/
using System;