1, navBarControl 修改背景色
右键 --> Run Designer --> View Choose --> AdvExploreBarView
Appearances -- > Background ( BackColor 和 BackColor2 )
2, SimpleButton 修改背景色
ButtonStyle --> 非 default
3, GridControl 设置交替行的背景色
Appearance --> EvenRow --> 相关 color 设置
AppearanceView --> Enable--EvenRowColor
4, 设置 grid Header居中
Appearance -> HeaderPanel --> HAlignment = center
5, grid 自动增加新行
OptionsBehavior --> AllowAddRows=true
OptionsView --> NewItemRowPosition = bottom
6, gridview 的相关事情 keyDown,mouseDown,focusedRowChanged
private void givMedia_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { if (givMedia.RowCount > 0) { if (IsNullOrEmptyObject(givMedia.GetFocusedRowCellValue(givMedia.Columns[0]))) { return; } sProjectID = givMedia.GetFocusedRowCellValue(givMedia.Columns[0]).ToString(); if (bShowBoard) { InitBoard(); } else { InitAttachment(); } } }
private void givMedia_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && e.Clicks == 2) // 判断是否是用鼠标双击 { DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo ghi = givMedia.CalcHitInfo(new Point(e.X, e.Y)); if (ghi.InRow) // 判断光标是否在行内 { DataEdit(); } } }
//按键 private void grvMain_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Control | e.KeyCode == Keys.F) // Ctrl + F 查找 { DataFind(); } else if (e.KeyCode == Keys.Control | e.KeyCode == Keys.N) // ctrl + N 新建 { DataAdd(); } else if (e.KeyCode == Keys.Control | e.KeyCode == Keys.D) // ctrl + D 筛选 { DataFilter(); } else if (e.KeyCode == Keys.Control | e.KeyCode == Keys.O) // ctrl + O 打开/编辑 { DataEdit(); } else if (e.KeyCode == Keys.Control | e.KeyCode == Keys.P) // ctrl + P 打印 { DataPrint(); } else if (e.KeyCode == Keys.Control | e.KeyCode == Keys.L) // ctrl + L 日志 { DataLog(); } else if (e.KeyCode == Keys.Delete) // delete键 删除 { DataDelete(); } }
7. gridview 列宽根据内容自动调整
gridview --> OptionsView --> ColumnsAutoWidth=false
初始化设置 gridControl.datasource 后,设置 gridView.BestFitColumns