From 8b404bae187ed85b650c9aece6602532c586f5ea Mon Sep 17 00:00:00 2001 From: lu <99954486@qq.com> Date: 星期三, 16 四月 2025 09:32:20 +0800 Subject: [PATCH] select from --- DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs | 73 +++++++++++++++++++++++++++++++++++- 1 files changed, 71 insertions(+), 2 deletions(-) diff --git a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs index 580873b..e74487a 100644 --- a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs +++ b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs @@ -28,6 +28,7 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; +using System.Windows.Forms.VisualStyles; using UserControls.Data; using static System.Windows.Forms.Control; @@ -1721,7 +1722,7 @@ } }; gridView1.OptionsView.ColumnAutoWidth = false;//鑷姩璋冩暣鍒楀 - + if (isPostSearch == true) { gridView1.OptionsView.ShowGroupPanel = false; @@ -2097,7 +2098,75 @@ return 0; return decimal.Parse(txt); } - + + + #region 缁樺埗琛ㄥご鍏ㄩ�夊嬀閫夋 + /// <summary> + /// 缁樺埗琛ㄥご鍏ㄩ�夊嬀閫夋 + /// </summary> + // private Rectangle checkBoxColumnHeaderRect = Rectangle.Empty; + // private GridColumn checkBoxColumn = null; + public static void CustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e) + { + Rectangle checkBoxColumnHeaderRect = new Rectangle(51, 1, 37, 57); + if (e.Column != null && e.Column.AbsoluteIndex == 0) + { + //X = 51 Y = 1 Width = 37 Height = 57 + e.Column.Caption = "."; + checkBoxColumnHeaderRect = e.Bounds; + // checkBoxColumn = e.Column; + //椤绘妸鍒楀ご鏍囬璁剧疆涓虹┖ + e.Painter.DrawObject(e.Info); + //鍦ㄥ垪澶翠腑蹇冩樉绀哄閫夋 + int x = e.Bounds.X + (int)((e.Bounds.Width - CheckBoxRenderer.GetGlyphSize(e.Graphics, CheckBoxState.UncheckedNormal).Width) * 0.5); + int y = e.Bounds.Y + (int)((e.Bounds.Height - CheckBoxRenderer.GetGlyphSize(e.Graphics, CheckBoxState.UncheckedNormal).Height) * 0.5); + Point location = new Point(x, y); + CheckBoxState checkBoxState; + if (e.Column.Tag != null && e.Column.Tag.ToString() == "1") + checkBoxState = CheckBoxState.CheckedPressed; + else + checkBoxState = CheckBoxState.UncheckedNormal; + CheckBoxRenderer.DrawCheckBox(e.Graphics, location, checkBoxState); + e.Handled = true; + } + } + + public static void CustomMouseUp(object sender, MouseEventArgs e, DevExpress.XtraGrid.GridControl gcMain, DevExpress.XtraGrid.Views.Grid.GridView gridView1) + { + GridColumn checkBoxColumn = gridView1.Columns[0]; + Rectangle checkBoxColumnHeaderRect = new Rectangle(51, 1, 37, 57); + if (checkBoxColumnHeaderRect != Rectangle.Empty) + { + if (e.X > checkBoxColumnHeaderRect.X && e.X < (checkBoxColumnHeaderRect.X + checkBoxColumnHeaderRect.Width) && e.Y > checkBoxColumnHeaderRect.Y && e.Y < (checkBoxColumnHeaderRect.Y + checkBoxColumnHeaderRect.Height)) + { + DataTable _Table = (DataTable)gcMain.DataSource; + if (checkBoxColumn.Tag != null && checkBoxColumn.Tag.ToString() == "1") + { + checkBoxColumn.Tag = "0"; + foreach (DataRow row in _Table.Rows) + { + row["chkInt"] = false; + } + } + else + { + checkBoxColumn.Tag = "1"; + foreach (DataRow row in _Table.Rows) + { + row["chkInt"] = true; + } + } + gcMain.BindingContext = new BindingContext(); + gcMain.DataSource = _Table; + gcMain.ForceInitialize(); + gridView1.CloseEditor(); + gridView1.PostEditor(); + gridView1.UpdateCurrentRow(); + gridView1.InvalidateColumnHeader(checkBoxColumn); + } + } + } + #endregion } /// <summary> -- Gitblit v1.9.3