public static void Grid_Set(GridView Gridv)
{
Gridv.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.Click; //整行
Gridv.OptionsBehavior.ReadOnly = true; //行只读
Gridv.OptionsBehavior.Editable = false; //不可编辑
Gridv.OptionsFind.AlwaysVisible = true; //查找”框一直显示
Gridv.OptionsSelection.MultiSelect = true;
Gridv.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect; //多选 Butten
Gridv.OptionsBehavior.AutoExpandAllGroups = true; //自动展开视图中的所有组
Gridv.OptionsSelection.EnableAppearanceFocusedCell = false;//选中单元格不变色
Gridv.OptionsView.ColumnAutoWidth = false;//水平滚动条有效
Gridv.Appearance.HeaderPanel.Options.UseTextOptions = true;
Gridv.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;//表头及行内容居中显示
Gridv.Appearance.HeaderPanel.TextOptions.VAlignment = VertAlignment.Center;
Gridv.Appearance.HeaderPanel.TextOptions.WordWrap = WordWrap.NoWrap; //
Gridv.Appearance.Row.TextOptions.HAlignment = HorzAlignment.Near;
Gridv.Appearance.Row.TextOptions.VAlignment = VertAlignment.Center;
Gridv.Appearance.Row.TextOptions.WordWrap = WordWrap.NoWrap;
Gridv.OptionsView.ShowGroupPanel =false;
Gridv.IndicatorWidth = 50;
Gridv.RowHeight = 20;
Gridv.BestFitColumns(); //自适应内容
Gridv.FindFilterText = "";
Gridv.OptionsView.ShowGroupPanel = false; //不允许自定义分组
Gridv.RowHeight = 22; //行高22
Gridv.OptionsView.ShowFooter = false; //不显示页脚
//表头行高设置为24、分组行高设置为35(为仅有一级分组的行高)
Gridv.ColumnPanelRowHeight = 24;
Gridv.GroupRowHeight = 35;
//列表中最前面的空白列的宽度设置为12
Gridv.IndicatorWidth = 12;
//设置列表是否多选、多选的模式(行或单元格)、选择的行或单元格背景是否倒置
Gridv.OptionsSelection.MultiSelect = true;
Gridv.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect;
Gridv.OptionsSelection.InvertSelection = true;
Gridv.OptionsSelection.EnableAppearanceFocusedCell = true;
//允许编辑
Gridv.OptionsBehavior.Editable = true;
//不显示分组面板
Gridv.OptionsView.ShowGroupPanel = false;
//不允许用户进行过滤和分组
Gridv.OptionsCustomization.AllowFilter = false;
Gridv.OptionsCustomization.AllowGroup = false;
//允许用户拖动列和不允许进行列排序
Gridv.OptionsCustomization.AllowColumnMoving = true;
Gridv.OptionsCustomization.AllowSort = true;
//列标题垂直居中
Gridv.Appearance.HeaderPanel.Options.UseTextOptions = true;
Gridv.Appearance.HeaderPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
Gridv.Appearance.HeaderPanel.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
//将数据行内容垂直,文字左对齐,数字右对齐
Gridv.Appearance.Row.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
Gridv.Appearance.Row.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
//HAlignment(水平位置):Far(数字右对齐)/Near(文字、日期左对齐)
//不显示右键菜单
Gridv.OptionsMenu.EnableColumnMenu = true;
//自动过滤时不显示过滤记录
Gridv.OptionsView.ShowFilterPanelMode = DevExpress.XtraGrid.Views.Base.ShowFilterPanelMode.Never;
}
DevExpress Gridview 常用设置
于 2022-11-22 10:51:58 首次发布