DevExpress GridView經常使用功能總結(二)

1)在GridView 行中添加Button按鈕html

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 設置標題行以及內容行數據居中ide

標題行 10 所述 在HeadPanel 裏有一個TextOptions 展開以後 將HAlignment : Center post

若是是將內容行數據居中.有兩種方法code

①逐行設置 htm

①GridView -> Run Designer -> Columns -> AppearanceCell -> TextOptions 找到HAlignment : Center .事件

②設置Appearencesget

GridView -> Run Designer -> Appearance -> ViewCaption -> TextOptions -> HAlignment : Centerit

3)GridView添加CheckBox並支持多選操做io

GridView : Run Designer -> OptionsSelection -> MultiSelect : True MultiSelectMode : CheckBoxRowSelectsed

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左右就比較適合一些了。

本文來源:慧都學院-企業級IT培訓平臺

相關文章
相關標籤/搜索