1.隱藏最上面的GroupPanel: gridView1.OptionsView.ShowGroupPanel=false; 2.得到當前選定記錄某欄位的值: sValue=Table.Rows[gridView1.FocusedRowHandle][FieldName].ToString(); ...
1.隱藏最上面的GroupPanel:
gridView1.OptionsView.ShowGroupPanel=false;
2.得到當前選定記錄某欄位的值:
sValue=Table.Rows[gridView1.FocusedRowHandle][FieldName].ToString();
3.數據只讀:
gridView1.OptionsBehavior.Editable=false;
4.不顯示MasterDetailView:
gridView1.OptionsDetail.EnableMasterViewMode=false;
5.修改最上面的GroupPanel內容:
gridView1.GroupPanelText="奔跑ing";
6.設置數據源:
gridControl1.DataSource = dt;
7.讀寫拷貝許可權設置:
只讀不可拷貝:
ColumnViewOptionsBehavior.Editable = False
只讀可拷貝:
ColumnViewOptionsBehavior.Editable = True
OptionsColumn.AllowEdit = True
OptionsColumn.ReadOnly = True
可編輯:
ColumnViewOptionsBehavior.Editable = True
OptionsColumn.AllowEdit = True
OptionsColumn.ReadOnly = False
8.模板列的設置:
到Columns中,在他的屬性中找到ColumnEdit.
以LookUpEdit為例:
首先從Designer左邊菜單In-Place Editor Repository中添加LookUpEdit.取名為Re1.然後.在他的Columns屬性中添加3列.Caption依次為:編號,姓名,性別.FieldName依次為:FID,FNAME,FSEX.然後將Re1的NullText設置成空.
AutoSearchColumnIndex屬性設置為2.ImmediatePopup屬性設置為True.
SearchMode設置為OnlyInPopup.
然後將這個模板列附加到我們上面提到的列1(也就是將列1的ColumnEdit屬性設成Re1)
最後我們還要在代碼裡面給Re1綁定數據源和顯示項.
Re1.DataSource = DALUse.Query("select fid,fname,fsex from dual").Tables[0];
Re1.DisplayMember = "FSEX";
Re1.ValueMember = "FNAME";
9.設某一列文字和標題局中顯示:
gridView1.Columns[0].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
gridView1.Columns[0].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
10.去掉某一列上面的自動篩選功能(Filter):
gridView1.Columns[0].OptionsFilter.AllowAutoFilter = false;
gridView1.Columns[0].OptionsFilter.AllowFilter = false;
gridView1.Columns[0].OptionsFilter.ImmediateUpdateAutoFilter = false;
11.設置凍結列(左凍結):
gridView1.Columns[0].Fixed= DevExpress.XtraGrid.Columns.FixedStyle.Left;
12.得到單元格數據(0行0列):
string ss=gridView1.GetRowCellDisplayText(0, gridView1.Columns[0]);
string ss = gridView1.GetRowCellValue(0, gridView1.Columns[0]);
13.設置單元格數據:
gridView1.SetRowCellValue(0, gridView1.Columns[0], "123");
14.設置自動增加的行號,需要先添加給gridview添加事件CustomDrawRowIndicator
private void gridview_CustomDrawRowIndicator(object sender,DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
15、如何讓各列頭禁止移動?
設置 gridView1.OptionsCustomization.AllowColumnMoving = false
16、如何讓各列頭禁止排序?
設置 gridView1.OptionsCustomization.AllowSort = false
17、如何禁止各列頭改變列寬?
設置 gridView1.OptionsCustomization.AllowColumnResizing = false
內容整理於互聯網