| | |
| | | using System.Text.RegularExpressions; |
| | | using System.Windows.Forms; |
| | | using System.Windows.Forms.VisualStyles; |
| | | using UserControls.Data; |
| | | using static System.Windows.Forms.Control; |
| | | |
| | | |
| | |
| | | txt.IsReadly = isEdt; |
| | | continue; |
| | | } |
| | | //自定义库位 |
| | | if (colType is UcLookKw) |
| | | { |
| | | var txt = colType as UcLookKw; |
| | | txt.SetIdOrCode(strVal); |
| | | txt.IsReadly = isEdt; |
| | | continue; |
| | | } |
| | | //自定义供应商 |
| | | if (colType is UcLookSupplier) |
| | | { |
| | |
| | | txt.IsReadly = isEdt; |
| | | continue; |
| | | } |
| | | //自定义库位 |
| | | if (ctrl is UcLookKw) |
| | | { |
| | | var txt = ctrl as UcLookKw; |
| | | txt.SetIdOrCode("-1"); |
| | | txt.IsReadly = isEdt; |
| | | continue; |
| | | } |
| | | //自定义供应商 |
| | | if (ctrl is UcLookSupplier) |
| | | { |
| | |
| | | if (ctrl is UcLookCk) |
| | | { |
| | | var txt = ctrl as UcLookCk; |
| | | txt.IsReadly = isEdt; |
| | | continue; |
| | | } |
| | | //自定义库位 |
| | | if (ctrl is UcLookKw) |
| | | { |
| | | var txt = ctrl as UcLookKw; |
| | | txt.IsReadly = isEdt; |
| | | continue; |
| | | } |
| | |
| | | } |
| | | public delegate void DelegateGetModel(string guid); |
| | | public delegate void DelegateGetList(int currentPage); |
| | | public delegate void DelegateGetUserControlList(); |
| | | |
| | | /// <summary> |
| | | /// |
| | |
| | | /// <param name="action2">委托2</param> |
| | | public static void SetGridViewParameter(GridView gridView1, PictureBox picCheckBox = null, Form fm = null, string fileName = "checkStatus", string icoName = "", DelegateGetModel action = null, DevExpress.Utils.ToolTipController tips = null, bool isPostSearch = true, DelegateGetModel action2 = null) |
| | | { |
| | | gridView1.PopupMenuShowing += (s, e) => |
| | | { |
| | | if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Column) |
| | | { |
| | | GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; |
| | | if (menu != null) |
| | | { |
| | | string[] ary = { "Column Chooser", "Hide This Column", "Clear All Sorting", "Clear Sorting", "Sort Descending", "Sort Ascending", "Best Fit (all columns)" }; |
| | | for (int i = menu.Items.Count - 1; i >= 0; i--) |
| | | { |
| | | string _caption = menu.Items[i].Caption; |
| | | if (!ary.Contains(_caption)) |
| | | { |
| | | menu.Items.Remove(menu.Items[i]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | //2025-11-06 cnf 引入中文插件注 |
| | | /* gridView1.PopupMenuShowing += (s, e) => |
| | | { |
| | | if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Column) |
| | | { |
| | | GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; |
| | | if (menu != null) |
| | | { |
| | | string[] ary = { "Column Chooser", "Hide This Column", "Clear All Sorting", "Clear Sorting", "Sort Descending", "Sort Ascending", "Best Fit (all columns)" }; |
| | | for (int i = menu.Items.Count - 1; i >= 0; i--) |
| | | { |
| | | string _caption = menu.Items[i].Caption; |
| | | if (!ary.Contains(_caption)) |
| | | { |
| | | menu.Items.Remove(menu.Items[i]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | };*/ |
| | | gridView1.OptionsView.ColumnAutoWidth = false;//自动调整列宽 |
| | | if (isPostSearch == true) |
| | | { |
| | |
| | | action2(_guid); |
| | | }; |
| | | } |
| | | gridView1.RowCellStyle += (s, e) => |
| | | { |
| | | GridView view = s as GridView; |
| | | if (view != null && e.Column != null && e.CellValue != null) |
| | | { |
| | | if (e.Column.FieldName.EndsWith("Color")) |
| | | { |
| | | int rowHandle = e.RowHandle; |
| | | if (rowHandle >= 0) |
| | | { |
| | | DataRow row = gridView1.GetDataRow(e.RowHandle); |
| | | string _bgColor = row[e.Column.FieldName + "Rgb"].ToString(); |
| | | if (!string.IsNullOrEmpty(_bgColor)) |
| | | { |
| | | Color bgColor = ColorTranslator.FromHtml(_bgColor); |
| | | e.Appearance.BackColor = bgColor; |
| | | //e.Appearance.BackColor2 = Color.LightSkyBlue; |
| | | //e.Appearance.ForeColor = ColorTranslator.FromHtml("#ffffff") ; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | gridView1.RowStyle += (s, e) => |
| | | { |
| | | //默认选中行不变色 |
| | |
| | | edit.SelectAll(); |
| | | } |
| | | |
| | | public static void SetGridLayout(GridView gridView1) |
| | | public static void SetGridLayout(GridView gridView1,int maxWidth=500) |
| | | { |
| | | foreach (GridColumn column in gridView1.Columns) |
| | | { |
| | | if (column.Width > 500) |
| | | column.Width = 500; |
| | | if (column.Width > maxWidth) |
| | | column.Width = maxWidth; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 设置选项卡 |
| | | /// </summary> |
| | |
| | | /// <param name="pageBar1"></param> |
| | | /// <param name="action"></param> |
| | | /// <param name="page"></param> |
| | | public static void SetTabParameter(GridView gridView1, DevExpress.XtraTab.XtraTabControl xtraTabControl1, UcPageBar pageBar1, DelegateGetModel action = null, DelegateGetList page = null, Label lbGuid = null) |
| | | public static void SetTabParameter(GridView gridView1, DevExpress.XtraTab.XtraTabControl xtraTabControl1, UcPageBar pageBar1, DelegateGetModel action = null, DelegateGetList page = null, Label lbGuid = null, UcToolBarMenu barMenu = null, DelegateGetUserControlList ucLst = null) |
| | | { |
| | | xtraTabControl1.SelectedPageChanged += (s, e) => |
| | | { |
| | | if (pageBar1 != null && xtraTabControl1.SelectedTabPageIndex == 0) |
| | | { |
| | | if (barMenu != null) |
| | | barMenu.SetAllButton(0); |
| | | |
| | | page(pageBar1.CurrentPage); |
| | | int rowHandle = 0; |
| | | rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], lbGuid.Text); |
| | | if (rowHandle < 0) |
| | | rowHandle = 0; |
| | | gridView1.FocusedRowHandle = rowHandle; |
| | | return; |
| | | } |
| | | |
| | | if (xtraTabControl1.SelectedTabPageIndex == 1) |
| | | { |
| | | int _handle = gridView1.FocusedRowHandle; |
| | |
| | | return; |
| | | } |
| | | action(_guid); |
| | | return; |
| | | } |
| | | if (pageBar1 != null && xtraTabControl1.SelectedTabPageIndex == 0) |
| | | |
| | | if (barMenu != null && xtraTabControl1.SelectedTabPageIndex == 2) |
| | | { |
| | | page(pageBar1.CurrentPage); |
| | | int rowHandle = 0; |
| | | rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], lbGuid.Text); |
| | | if (rowHandle < 0) |
| | | rowHandle = 0; |
| | | gridView1.FocusedRowHandle = rowHandle; |
| | | barMenu.SetAllButton(2); |
| | | ucLst(); |
| | | return; |
| | | } |
| | | }; |
| | | } |
| | |
| | | /// <param name="icoName"></param> |
| | | public static void SetGridViewParameterMx(GridView gridView1, DevExpress.Utils.ToolTipController tips = null) |
| | | { |
| | | gridView1.PopupMenuShowing += (s, e) => |
| | | { |
| | | if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Column) |
| | | { |
| | | GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; |
| | | if (menu != null) |
| | | { |
| | | string[] ary = { "Column Chooser", "Hide This Column", "Clear All Sorting", "Clear Sorting", "Sort Descending", "Sort Ascending", "Best Fit (all columns)" }; |
| | | for (int i = menu.Items.Count - 1; i >= 0; i--) |
| | | { |
| | | string _caption = menu.Items[i].Caption; |
| | | if (!ary.Contains(_caption)) |
| | | { |
| | | menu.Items.Remove(menu.Items[i]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | gridView1.OptionsView.ShowGroupPanel = false; |
| | | gridView1.OptionsCustomization.AllowGroup = false; |
| | | //2025-11-06 cnf 注 |
| | | /* gridView1.PopupMenuShowing += (s, e) => |
| | | { |
| | | if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Column) |
| | | { |
| | | GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; |
| | | if (menu != null) |
| | | { |
| | | string[] ary = { "Column Chooser", "Hide This Column", "Clear All Sorting", "Clear Sorting", "Sort Descending", "Sort Ascending", "Best Fit (all columns)" }; |
| | | for (int i = menu.Items.Count - 1; i >= 0; i--) |
| | | { |
| | | string _caption = menu.Items[i].Caption; |
| | | if (!ary.Contains(_caption)) |
| | | { |
| | | menu.Items.Remove(menu.Items[i]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | gridView1.OptionsView.ShowGroupPanel = false; |
| | | gridView1.OptionsCustomization.AllowGroup = false;*/ |
| | | |
| | | // gridView1.OptionsView.Alignment = DataGridViewContentAlignment.MiddleLeft; |
| | | foreach (GridColumn column in gridView1.Columns) |
| | |
| | | } |
| | | |
| | | |
| | | #region GridView汇总配置工具方法 |
| | | /// <summary> |
| | | /// 2025-08-14 kyy 快速配置GridView底部汇总(启用汇总行+设置列求和汇总) |
| | | /// </summary> |
| | | /// <param name="gridView">目标GridView控件</param> |
| | | /// <param name="summaryColumns">需要进行求和汇总的列名数组</param> |
| | | public static void SetupGridSummary(DevExpress.XtraGrid.Views.Grid.GridView gridView, params string[] summaryColumns) |
| | | { |
| | | // 启用底部汇总行 |
| | | gridView.OptionsView.ShowFooter = true; |
| | | |
| | | // 为每个指定列设置求和汇总 |
| | | foreach (var columnName in summaryColumns) |
| | | { |
| | | // 验证列是否存在(避免异常) |
| | | if (gridView.Columns[columnName] != null) |
| | | { |
| | | gridView.Columns[columnName].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum; |
| | | gridView.Columns[columnName].SummaryItem.DisplayFormat = "合计: {0}"; |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 数据过滤 |
| | | /// </summary> |