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) // 判斷光標是否在行內(nèi)
- {
- 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 列寬根據(jù)內(nèi)容自動調(diào)整
gridview --> OptionsView --> ColumnsAutoWidth=false
初始化設置 gridControl.datasource 后,,設置 gridView.BestFitColumns
|