紧接着前文《DevExpress GridView常用功能总结(二)》
1)在GridView 行中添加Button按钮
1 public void ButtonInitial() 2 { 3 RepositoryItemButtonEdit rib = new RepositoryItemButtonEdit(); 4 rib.TextEditStyle = TextEditStyles.HideTextEditor; 5 rib.Buttons[0].Kind = ButtonPredefines.Glyph; 6 rib.ButtonClick += rib_ButtonClick; 7 rib.Buttons[0].Caption = "详细信息"; 8 rib.Buttons[0].Visible = true; 9 gridView1.Columns["DOWNSTATE"].ColumnEdit = rib; 10 11 } 12 13 void rib_ButtonClick(object sender, ButtonPressedEventArgs e) 14 { 15 int rowindex = gridView1.FocusedRowHandle; 16 DataRow row = gridView1.GetDataRow(rowindex); 17 } View Code
2)GridView 设置标题行以及内容行 数据居中
标题行 10 所述 在HeadPanel 里有一个TextOptions 展开之后 将HAlignment : Center
如果是将内容行数据居中.有两种方法
①逐行设置
①GridView -> Run Designer -> Columns -> AppearanceCell -> TextOptions 找到HAlignment : Center .
②设置Appearences
GridView -> Run Designer -> Appearance -> ViewCaption -> TextOptions -> HAlignment : Center
3)GridView添加CheckBox 并支持多选操作
GridView : Run Designer -> OptionsSelection -> MultiSelect : True MultiSelectMode : CheckBoxRowSelect
4)GridView 添加 序号 列
GridView : Run Designer -> Event -> CustomDrawRowIndicator
在事件中添加代码 :
1 e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; 2 if (e.Info.IsRowIndicator) 3 { 4 if (e.RowHandle >= 0) 5 { 6 e.Info.DisplayText = (e.RowHandle + 1).ToString(); 7 } 8 else if (e.RowHandle < 0 && e.RowHandle > -1000) 9 { 10 e.Info.Appearance.BackColor = System.Drawing.Color.AntiqueWhite; 11 e.Info.DisplayText = "G" + e.RowHandle.ToString(); 12 } 13 }
另外在 Run Desginer -> IndicatorWidth 设置序号列的宽度 一般30左右就比较适合一些了.
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/922.html
相关产品: .NET开发框架eXpressApp Framework(XAF), DevExpress Universal Subscription,