首页 > 编程语言 >C# DevExpress中GridControl控件的基本属性设置和使用方法

C# DevExpress中GridControl控件的基本属性设置和使用方法

时间:2022-10-09 10:48:23浏览次数:56  
标签:控件 Designer Run 鼠标 单击 C# DevExpress gridView1

1.GridControl隐藏GroupPanel(主面板)

隐藏:鼠标单击Run Designer-OptionsView-ShowGroupPanel=False;

修改:鼠标单击Run Designer-Appearance-GroupPanelText="检索信息";

this.gridView1.OptionsView.ShowGroupPanel = false;//隐藏

this.gridView1.GroupPanelText = "检索信息";

2.GridControl禁用标题列右键菜单

鼠标单击Run Designer-OptionsMenu-EnableColumnMenu=False;

this.gridView1.OptionsMenu.EnableColumnMenu = false;//后台代码实现

3.GridControl隐藏标题列信息

鼠标单击Run Designer-OptionsView-ShowColumnHeaders=False;

this.gridView1.OptionsView.ShowColumnHeaders = false;//后台代码实现

4.GridControl显示最左边的空白列并且设置它的宽度,把生成的序号在这个空白列中显示出来

显示左边空白列:鼠标单击Run Designer-OptionsView-ShowIndicator=True;

设置宽度:鼠标单击Run Designer-Appearance-IndicatorWidth=50;

复制代码
this.gridView1.OptionsView.ShowIndicator = true;// 显示最左边空白列
this.gridView1.IndicatorWidth = 50;//设置最左边空白列的宽度

//启用事件生成序号
this.gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.gridView1_CustomDrawRowIndicator);

#region 生成序号
private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
if (e.Info.Kind == DevExpress.Utils.Drawing.IndicatorKind.Header)
{
e.Info.DisplayText = "行号";//设置列名称
}
e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;//设置列居中显示
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
{
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
}
#endregion

复制代码

5.GridControl取消点击后的虚线框

修改:鼠标单击Run Designer-Appearance-FocusRectStyle=None;

this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.None;

6.GridControl禁用列宽自适应(总宽度超出桌面宽度显示水平滚动条)

鼠标单击Run Designer-OptionsView-ColumnAutoWidth=False;

this.gridView1.OptionsView.ColumnAutoWidth = false; 

7.GridControl禁用标题列过滤

鼠标单击Run Designer-OptionsCustomization-AllowFilter=False;

this.gridView1.OptionsCustomization.AllowFilter = false;

8.GridControl禁用标题列排序(点击标题列升序(降序))

鼠标单击Run Designer-OptionsCustomization-AllowSort=False;

 this.gridView1.OptionsCustomization.AllowSort = false;

9.GridControll禁用标题列移动(拖动列改变列的位置)

鼠标单击Run Designer-OptionsCustomization-AllowColumnMoving=False;

this.gridView1.OptionsCustomization.AllowColumnMoving = false;

10.GridControll禁用标题列改变宽度(拖动列改变列的宽度)

鼠标点击Run Designer-OptionsCustomization-AllowColumnResizing=False;

this.gridView1.OptionsCustomization.AllowColumnResizing = false;

11.GridControll禁用标题列分组

鼠标单击Run Designer-OptionsCustomization-AllowGroup=False;

this.gridView1.OptionsCustomization.AllowGroup = false;

12.GridControll是否显示过滤面板

鼠标单击Run Designer-OptionsCustomization-AllowGroup=False;

this.gridView1.OptionsView.ShowFilterPanelMode = DevExpress.XtraGrid.Views.Base.ShowFilterPanelMode.Never;

13.GridControll设置奇数行颜色为红色

设置奇数行改变颜色:置鼠标点击Run Designer-OptionsView-EnableAppearanceOddRow=True;

设置奇数行的颜色:鼠标点击Run Designer-Appearance-OddRow-BackColor=System.Drawing.Color.Red;

this.gridView1.OptionsView.EnableAppearanceOddRow = true;//奇数行颜色变化
this.gridView1.Appearance.OddRow.BackColor = System.Drawing.Color.Red;//奇数行颜色设置

14.GridControll设置偶数行颜色为蓝色

设置偶数行改变颜色:置鼠标点击Run Designer-OptionsView-EnableAppearanceEvenRow=True;

设置偶数行的颜色:鼠标点击Run Designer-Appearance-EvenRow-BackColor=System.Drawing.Color.Blue;

this.gridView1.OptionsView.EnableAppearanceEvenRow = true;//偶数行颜色变化
this.gridView1.Appearance.EvenRow.BackColor = System.Drawing.Color.Blue;//偶数行颜色设置

15.GridControll设置列中的数据只读

设置编辑:鼠标单击Run Designer-OptionsBehavior-Editable=False;

this.gridView1.OptionsBehavior.Editable = false;

16.GridControll设置只能选择行并且数据不能编辑

设置只能选中整行:鼠标单击Run Designer-OptionsBehavior-EditorShowMode=DevExpress.Utils.EditorShowMode.Click;

设置列的数据不能编辑:鼠标单击Run Designer-OptionsBehavior-Editable=False;

this.gridView1.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.Click;//设置只能选中整行
this.gridView1.OptionsBehavior.Editable = false;//设置列的数据不能编辑

17.GridControll设置列中的数据只读并且不可拷贝

设置数据可编辑:鼠标单击Run Designer-OptionsBehavior-Editable=True;

设置数据只读并且不可拷贝:鼠标单击Run Designer-OptionsBehavior-ReadOnly=True;

gridView1.OptionsBehavior.Editable = true;//设置列能编辑
gridView1.OptionsBehavior.ReadOnly = true;//设置设置只读并且不可拷贝 

18.GridControll设置指定列中的数据只读不可拷贝

设置列能编辑: 鼠标单击Run Designer-OptionsBehavior-Editable=False;

设置单元格能编辑: 鼠标单击Run Designer-Columns- 列名称-OptionsColumn-AllowEdit=True;

设置单元格只读并且不能拷贝: 鼠标单击Run Designer-Columns- 列名称-OptionsColumn-ReadOnly=True;

gridView1.OptionsBehavior.Editable = true;//设置列能编辑
列名称.OptionsColumn.AllowEdit = true;// 设置单元格能编辑        默认:true
列名称.OptionsColumn.ReadOnly = true;//设置单元格只读并且不能拷贝  默认:false 

19.GridControll设置只能选中整行并且列中的数据不能编辑并且选中列的颜色跟着改变

设置只能选中整行:鼠标单击Run Designer-OptionsBehavior-EditorShowMode=DevExpress.Utils.EditorShowMode.Click;

设置列的数据不能编辑:鼠标单击Run Designer-OptionsBehavior-Editable=False;

设置选中列的颜色跟着改变:鼠标单击Run Designer-OptionsSelection-EnableAppearanceFocusedCell=True;

this.gridView1.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.Click;//设置只能选中整行
this.gridView1.OptionsBehavior.Editable = false;//设置列的数据不能编辑
this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;//选中列的颜色跟着改变

20.GridControll禁用自动填充列

鼠标单击Run Designer-OptionsBehavior-AutoPopulateColumns=False;

this.gridView1.OptionsBehavior.AutoPopulateColumns = false;

21.GridControll选中整行

鼠标单击Run Designer-OptionsSelection-EnableAppearanceFocusedRow=True;

this.gridView1.OptionsSelection.EnableAppearanceFocusedRow = true;

22.GridControll启用列的多选,列的选择方式(CellSelect:多选单元格 CheckBoxRowSelect:复选框 RowSelect:多选行)

启用列的多选:鼠标单击Run Designer-OptionsSelection-MultiSelect=True;

设置列为复选框多选:鼠标单击Run Designer-OptionsSelection-MultiSelectMode=DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;

this.gridView1.OptionsSelection.MultiSelect = true; 
this.gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect; 

注:选中事件:SelectionChanged()、focusedRowChanged(),当选择的模式是单行时,须使用focusedRowChanged()

23.GridControll设置标题列居中

鼠标单击Run Designer-Appearance-HeaderPanel-TextOptions-HAlignment=DevExpress.Utils.HorzAlignment.Center;

this.gridView1.Appearance.HeaderPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;

24.GridControll不使用TAB/SHIFT+TAB移动焦点

鼠标单击Run Designer-OptionsNavigation-UseTabKey=True;

gridView1.OptionsNavigation.UseTabKey = true;

25.GridControll显示合计

鼠标单击Run Designer-OptionsView-ShowFooter=True;

设置指定列的合计:Run Designer-Columns-选择列名称-SummaryItem-SummaryType=Sum;

复制代码
this.gridView1.OptionsView.ShowFooter = true;

//动态创建GridColumn列的时候设置
#region 第一种方式
//age:列名称
age.SummaryItem.DisplayFormat = "{0:f2}";//设置显示格式
age.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;//汇总方式
#endregion
#region 第二种方式
//age:列名称 DevExpress.Data.SummaryItemType.Sum:汇总方式 {0:n2}:显示格式
age.Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] {
new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Sum, "age", "{0:n2}")});
#endregion

复制代码

26.GridControll设置列中的数据自动换行

鼠标单击Run Designer-OptionsView-RowAutoHeight=True;

给指定列设置控件:Run Designer-Columns-选择列名称-ColumnEdit选择“MemoEdit”;

复制代码
this.gridView1.OptionsView.RowAutoHeight = true;//设置自动换行

#region 创建一个文本控件
DevExpress.XtraEditors.Repository.RepositoryItemMemoEdit memoEdit = new DevExpress.XtraEditors.Repository.RepositoryItemMemoEdit();
memoEdit.AutoHeight = false;
memoEdit.Name = "memoEdit";
#endregion

school.ColumnEdit = memoEdit;//school:表示列 在创建GridColumn列的时候设置ColumnEdit的值

复制代码

27.GridControll设置相同列合并

鼠标单击Run Designer-OptionsView-AllowCellMerge=True;

复制代码
this.gridView1.OptionsView.AllowCellMerge = true;//启用合并列
// 启用指定合并列事件 this.gridView1.CellMerge += new DevExpress.XtraGrid.Views.Grid.CellMergeEventHandler(gridView1_CellMerge);

#region 合并指定的列
private void gridView1_CellMerge(object sender, DevExpress.XtraGrid.Views.Grid.CellMergeEventArgs e)
{
int rowHandle1 = e.RowHandle1;//合并列的第一行
int rowHandle2 = e.RowHandle2;//合并列从1开始到最后行就是
string strValue1 = this.gridView1.GetListSourceRowCellValue(rowHandle1, "age").ToString();//age:列名称
string strValue2 = this.gridView1.GetListSourceRowCellValue(rowHandle2, "age").ToString();//age:列名称
if (strValue1 != strValue2)
{
e.Merge = false; //值相同的2个单元格是否要合并在一起
e.Handled = true; //合并单元格是否已经处理过,无需再次进行省缺处理
}
}
#endregion

复制代码

28.GridControll显示自带的 搜索功能 

鼠标单击Run Designer-OptionsFind-AlwaysVisible=True;

this.gridView1.OptionsFind.AlwaysVisible = true;

29.GridControll控件绑定数据源

gridControl1.DataSource = dt;//dt 数据源可以是DataTable也可以是List集合

30.GridControll控件没有绑定数据源或者查询出来的数据为0条记录时显示自定义的提示语句

复制代码
//启用事件
this.gridView1.CustomDrawEmptyForeground += new DevExpress.XtraGrid.Views.Base.CustomDrawEventHandler(this.gridView1_CustomDrawEmptyForeground);

//具体实现的提示语句
private void gridView1_CustomDrawEmptyForeground(object sender, DevExpress.XtraGrid.Views.Base.CustomDrawEventArgs e)
{
DevExpress.XtraGrid.Views.Base.ColumnView columnView = sender as DevExpress.XtraGrid.Views.Base.ColumnView;
BindingSource bindingSource = this.gridView1.DataSource as BindingSource;
if (bindingSource == null || bindingSource.Count == 0)
{
string str = "没有查询到你所想要的数据!";
Font f = new Font("宋体", 10, FontStyle.Bold);
Rectangle r = new Rectangle(e.Bounds.Top + 105, e.Bounds.Left + 5, e.Bounds.Right - 5, e.Bounds.Height - 5);
e.Graphics.DrawString(str, f, Brushes.Black, r);
}
}

复制代码

31.GridControll添加新行

新增行: gridView1.AddNewRow();

实现 gridView_InitNewRow 事件(对于新加行的特别的设置)

复制代码
//启用事件
this.gridView1.InitNewRow += new DevExpress.XtraGrid.Views.Grid.InitNewRowEventHandler(gridView1_InitNewRow);

//添加行按钮事件
private void btn_addRow_Click(object sender, EventArgs e)
{
//注:在添加行的时候必须先给“gridControl1.DataSource”绑定数据源不然添加会没有任何反映
gridView1.AddNewRow();
}
//新增行
private void gridView1_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
{
#region 根据列名添加数据:“name”列名称-值 “王大”
//DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
//view.SetRowCellValue(e.RowHandle, view.Columns["name"], "王大");
//view.SetRowCellValue(e.RowHandle, view.Columns["age"], "20");
#endregion
#region 复制最后一行
DevExpress.XtraGrid.Views.Base.ColumnView View = sender as DevExpress.XtraGrid.Views.Base.ColumnView;
View.SetRowCellValue(e.RowHandle, View.Columns[0], gridView1.GetRowCellValue(gridView1.GetRowHandle(gridView1.RowCount - 2), gridView1.Columns[0])); //复制最后一行的数据到新行
View.SetRowCellValue(e.RowHandle, View.Columns[1], gridView1.GetRowCellValue(gridView1.GetRowHandle(gridView1.RowCount - 2), gridView1.Columns[1])); //复制最后一行的数据到新行
#endregion
#region 只添加一行,没有如何数据
//Application.DoEvents();
//try
//{
// this.gridView1.BeginInit();
// this.gridControl1.Focus();//获取光标
// this.gridView1.Focus();//获取光标
// this.gridView1.SelectCell(e.RowHandle, this.gridView1.Columns["列名称"]);//选中列
// this.gridView1.FocusedColumn = this.gridView1.Columns["列名称"];//设置焦点行的焦点单元格的位置
// this.gridView1.ShowEditor();//设置编辑状态的列
//}
//finally
//{
// this.gridView1.EndInit();
//}
#endregion
}

复制代码

32.GridControll删除行

gridView1.DeleteSelectedRows();

33.GridControll定位到某行

复制代码
//第一行
this.gridView1.MoveFirst();

//下一行
this.gridView1.MoveNext();

//最后一行
this.gridView1.MoveLast();

复制代码

33.GridControll指定列内容显示居中

启用列的文本选项: 鼠标单击Run Designer-Columns- 列名称-Appearance-AppearanceCell-Options-UseTextOptions=True;

设置列的文本居中: 鼠标单击Run Designer-Columns- 列名称-Appearance-AppearanceCell-TextOptions-HAlignment=Center;

列名称.AppearanceCell.Options.UseTextOptions = true;
列名称.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;

34.GridControll去掉指定列上的自动筛选功能

鼠标单击Run Designer-Columns- 列名称-Options-OptionsFilter-AllowAutoFilter=False;

鼠标单击Run Designer-Columns- 列名称-Options-OptionsFilter-AllowFilter=False;

鼠标单击Run Designer-Columns- 列名称-Options-OptionsFilter-ImmediateUpdateAutoFilter=False;

列名称.OptionsFilter.AllowAutoFilter = false;
列名称.OptionsFilter.AllowFilter = false;
列名称.OptionsFilter.ImmediateUpdateAutoFilter = false;

35.GridControll设置指定列左固定(冻结在左边)

列名称.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left;

36.GridControll获取指定列中的数据

string texts = gridView1.GetRowCellDisplayText(1, gridView1.Columns[3]);//获取第一行四列中的数据
string values = gridView1.GetRowCellValue(2, gridView1.Columns["列名称"]).ToString();//获取第二行指定列的数据

37.GridControll设置单元格数据(将0行4列的单元格赋值111)

gridView1.SetRowCellValue(0, gridView1.Columns[3], "111");//0:行号 gridView1.Columns[3]:列  111:赋值内容

 38.GridControll设置获取焦点

复制代码
//设置自定义行的焦点
this.gridView1.FocusedRowHandle = 3;

//获取焦点行的下标
int lineNumber = this.gridView1.FocusedRowHandle;
//获取焦点行的下标
DevExpress.XtraGrid.Views.Base.ColumnView newview = (DevExpress.XtraGrid.Views.Base.ColumnView)gridControl1.FocusedView;
lineNumber = newview.FocusedRowHandle;

//根据列名称获取焦点行中任意单元格的值
DevExpress.XtraGrid.Views.Base.ColumnView cv = (DevExpress.XtraGrid.Views.Base.ColumnView)gridControl1.FocusedView;
int focusedhandle = cv.FocusedRowHandle;
object rowIdObj = gridView1.GetRowCellValue(focusedhandle, "age");//“age”表示:列名称
if (DBNull.Value != rowIdObj)
{
int age = Convert.ToInt32(rowIdObj);
}

//根据列名称设置焦点行的焦点单元格
DevExpress.XtraGrid.Views.Base.ColumnView view = (DevExpress.XtraGrid.Views.Base.ColumnView)gridControl1.FocusedView;
view.FocusedColumn = view.Columns["classs"];//“classs”表示:列名称

复制代码

39.GridControll自定义绘制表格颜色

复制代码
//启用事件
this.gridView1.CustomDrawCell += new DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventHandler(this.gridView1_CustomDrawCell);

private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
if (e.Column.FieldName.Equals("age"))//列名称
{
DevExpress.XtraGrid.Views.Grid.ViewInfo.GridCellInfo cellInfo = e.Cell as DevExpress.XtraGrid.Views.Grid.ViewInfo.GridCellInfo;
if (cellInfo.IsDataCell)
{
if (double.Parse(cellInfo.CellValue.ToString()) < 20)//年龄小于20
{
e.Appearance.BackColor = Color.OrangeRed;
}
else if (double.Parse(cellInfo.CellValue.ToString()) < 100)//年龄小于100
{
e.Appearance.BackColor = Color.YellowGreen;
}
else
{
e.Appearance.BackColor = Color.Gold;
}
}
}
}

复制代码

 40.GridControll根据动态条件自动义绘制指定行的颜色

复制代码
 //启用事件
this.gridView1.RowStyle += new DevExpress.XtraGrid.Views.Grid.RowStyleEventHandler(this.gridView1_RowStyle);

private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
{
DevExpress.XtraGrid.Views.Grid.GridView View = sender as GridView;
if (e.RowHandle >= 0)
{
object needAlert = View.GetRowCellValue(e.RowHandle, View.Columns["age"]);
if (needAlert != null & needAlert != DBNull.Value && needAlert.ToString().Trim() != "0" )
{
decimal AverValue = Convert.ToDecimal(View.GetRowCellValue(e.RowHandle, View.Columns["age"]));
if ( AverValue > 50)
{
e.Appearance.ForeColor = Color.Red;
e.Appearance.BackColor = Color.LightGray;
}
}
}
}

复制代码

41.GridControll自定义列显示文本

复制代码
//启用事件
this.gridView1.CustomColumnDisplayText += new DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventHandler(this.gridView1_CustomColumnDisplayText);

private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
{
if (e.Value != null && e.Value.ToString().Length > 0)
{
if (e.Column.FieldName == "gender")
{
e.DisplayText = e.Value.ToString().Trim()=="1"?"男":"女";
}
}
}

复制代码

 41.动态创建列并且设置一些基本的列属性

复制代码
//创建DataTable赋值并给gridControl指定数据源
private void CreateData()
{
     DataTable dt = new DataTable();
     dt.Columns.Add("name", Type.GetType("System.String"));
     dt.Columns.Add("age", Type.GetType("System.String"));
     dt.Columns.Add("gender", Type.GetType("System.String"));
     dt.Columns.Add("school", Type.GetType("System.String"));
     dt.Columns.Add("classs", Type.GetType("System.String"));
     for (int i = 0; i < 5; i++)
     {
         DataRow row = dt.NewRow();
         row["name"] = "张三" + i;
         if (i == 0 || i == 1)
            row["age"] = "18";
         else
            row["age"] = "18" + i;
         row["gender"] = "1";
         row["school"] = "理工大学理工大学理工大学理工大学理工大学理工大学理工大学理工大学理工大学理工大学理工大学理工大学" + i;
         row["classs"] = "天才2021级" + i;
         dt.Rows.InsertAt(row, i);
     }
     gridControl1.DataSource = dt;//表格获取数据源
}

//创建列、表格中控件的创建和列的一些属性设置
private void CreateColumn()
{
#region 创建一个文本控件
DevExpress.XtraEditors.Repository.RepositoryItemMemoEdit memoEdit = new DevExpress.XtraEditors.Repository.RepositoryItemMemoEdit();
memoEdit.AutoHeight = false;
memoEdit.Name = "memoEdit";
#endregion


#region 设置列的属性
GridColumn name = new GridColumn();
name.Caption = " 姓名";//显示名称
name.FieldName = "name";//数据源名称
name.Width = 50;//宽度
name.Visible = true;//是否显示
name.OptionsColumn.AllowEdit = true;// 单元格能编辑
name.OptionsColumn.ReadOnly = false;//设置只读
name.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left;//把本列固定在左边
this.gridView1.Columns.Add(name);//给指定的“GridBand”("基本信息")添加列

GridColumn age = new GridColumn();
age.Caption = "年龄";
age.FieldName = "age";
age.Width = 45;
age.Visible = true;
age.AppearanceCell.Options.UseTextOptions = true;
age.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
age.SummaryItem.DisplayFormat = "{0:f2}";//设置显示格式
age.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;//汇总方式
this.gridView1.Columns.Add(age);

GridColumn gender </span>= <span style="color: rgba(0, 0, 255, 1)">new</span><span style="color: rgba(0, 0, 0, 1)"> GridColumn();
gender.Caption </span>= <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">性别</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">;
gender.AppearanceCell.Options.UseTextOptions </span>= <span style="color: rgba(0, 0, 255, 1)">true</span>;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">启动设置文本显示</span>
gender.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">设置文本居中</span>
gender.OptionsFilter.AllowAutoFilter = <span style="color: rgba(0, 0, 255, 1)">false</span>;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">设置列不能筛选</span>
gender.OptionsFilter.AllowFilter = <span style="color: rgba(0, 0, 255, 1)">false</span>;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">设置列不能筛选</span>
gender.OptionsFilter.ImmediateUpdateAutoFilter = <span style="color: rgba(0, 0, 255, 1)">false</span>;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">设置列不能筛选</span>
gender.FieldName = <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">gender</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">;
gender.MinWidth </span>= <span style="color: rgba(128, 0, 128, 1)">45</span><span style="color: rgba(0, 0, 0, 1)">;
gender.Visible </span>= <span style="color: rgba(0, 0, 255, 1)">true</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.gridView1.Columns.Add(gender);

GridColumn school </span>= <span style="color: rgba(0, 0, 255, 1)">new</span><span style="color: rgba(0, 0, 0, 1)"> GridColumn();
school.Caption </span>= <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">学校</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">;
school.FieldName </span>= <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">school</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">;
school.ColumnEdit </span>=<span style="color: rgba(0, 0, 0, 1)"> memoEdit;
school.MinWidth </span>= <span style="color: rgba(128, 0, 128, 1)">100</span><span style="color: rgba(0, 0, 0, 1)">;
school.Visible </span>= <span style="color: rgba(0, 0, 255, 1)">true</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.gridView1.Columns.Add(school);

GridColumn classs </span>= <span style="color: rgba(0, 0, 255, 1)">new</span><span style="color: rgba(0, 0, 0, 1)"> GridColumn();
classs.Caption </span>= <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">班级</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">;
classs.FieldName </span>= <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">classs</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">;
classs.MinWidth </span>= <span style="color: rgba(128, 0, 128, 1)">80</span><span style="color: rgba(0, 0, 0, 1)">;
classs.Visible </span>= <span style="color: rgba(0, 0, 255, 1)">true</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.gridView1.Columns.Add(classs);
</span><span style="color: rgba(0, 0, 255, 1)">#endregion</span><span style="color: rgba(0, 0, 0, 1)">

}

复制代码

 

搜索

复制

标签:控件,Designer,Run,鼠标,单击,C#,DevExpress,gridView1
From: https://www.cnblogs.com/mkmkbj/p/16771297.html

相关文章

  • docker安装clickhouse以及相关的语法操作
    第一步:先拉取clickhouse镜像(dockerpullyandex/clickhouse-server) 第二步:再拉取clickhouses客户端(为以后连接clickhouses数据库:dockerpullyandex/clickhouse-client......
  • ISP-55e0-WCH 用于 CH55x、CH57x 和 CH32Fx 的 ISP 闪存工具
    该工具旨在通过USB在Linux上通过USB闪存WinChipHeadCH55x/CH57x/CH32Fx系列,例如CH551、CH552、CH554、CH559、CH579。当设置为ISP模式时,芯片创建一个4348:55......
  • mysql 删除索引 Cannot drop index 'IX_t_billing_setup_CustomerID_WarehouseID': n
     --创建表createtablet_billing_setup(BillingSetupIDintnotnullauto_incrementcomment'编号',CustomerIDintnotnullcomment'',......
  • AtCoder Beginner Contest 272 D Root M Leaper
    RootMLeaper\(bfs\)模拟先把能走的矩阵预处理出来,然后直接跑\(bfs\)要注意各种边界#include<iostream>#include<cstdio>#include<array>#include<queue>us......
  • 集成125K低频触发和2.4G发射单SOC芯片-CSM2433
    CSM2433是一款集成2.4GHz频段发射器、125KHz接收器和8位RISC(精简指令集)MCU的SOC芯片;125K低频接收性能:  ◼接收工作在15KHz-150KHz◼具有超低功耗自动发......
  • TCP与UDP的联系与区别?
    TCP(TransmissionControlProtocol,传输控制协议)是面向连接的协议,也就是说,在收发数据前,必须和对方建立可靠的连接。一个TCP连接必须要经过三次“对话”才能建立起来:1)主机A......
  • centos7.x重置系统密码
      centos7单用户模式更改计算机密码重启——在第一行按e——找到linux16的一行,在最后面加上rd.break(如果是虚拟机还需要加上console=tty0)——ctrl+x重......
  • redis-cli pipe 管道
    cat formattedData.txt |redis-cli-h10.11.0.71-p6385--pipe#coding=utf-8importsysimportMySQLdboutputFile="formattedData.txt"delimiter="\r\n"forli......
  • c++ 指针
    typedefchar*pstring;constpstringcstr=0;cstr是指向char的常量指针constpstring*ps;ps是一个指针,他的对象是一个指向char的常量指针。constpstring......
  • 关于Microsoft Office Outlook-邮件搜索方法记录
     Outlook(MicrosoftOffice套装软件组件)一般指MicrosoftOutlookMicrosoftOfficeOutlook是微软办公软件套装的组件之一,它对Windows自带的Outlookexpress的功能进行了扩......