Dev Express 常用的方法介绍
- 新增行
grvList.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom;
grvList.OptionsBehavior.Editable = true;
- 合并列
grvList.OptionsView.AllowCellMerge = true;
grvList.Columns["Date"].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.False;
- 特定列可否编辑
grvList.Columns["Invoice"].OptionsColumn.AllowEdit = false;
- Grid加Checkbox
grvList.Columns["CheckMarkSelection"].VisibleIndex = 0;
- Grid加LookUpEdit并绑定枚举数据
grdList.AddEnumDataSource<EnumAccountDefinition>("AccountDefinition");
- Grid加LookUpEdit并绑定数据
varVATAccountList=new List<VATAccountDTO>();
VATAccountList.LoadAll();
grdList.AddLookUpEdit(VATAccountList,"VATAccountID", "Name", new string[] { "Name","VatCode", "Description" });
- Grid 设置列标题不可以拖放
grvList.Columns["Message"].OptionsColumn.AllowMove = false;
- Grid样式,只能选择行
grvList.OptionsSelection.EnableAppearanceFocusedCell = false;
- Grid统计
grvList.OptionsView.ShowFooter = true;
grvList.Columns["DebitAmount"].SummaryItem.FieldName = "DebitAmount";
grvList.Columns["DebitAmount"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
- LookUpEdit绑定数据并控制列显示
var dsCountries = _presenter.GetCountryList();
lueCountry.PopulateData(dsCountries, "Name", new string[] { "Name" }, new string[] { "Name" });
- LookUpEdit绑定枚举
lueDCType.EnumDataSource<DCType>();
- LookUpEdit 编辑模式
cboCodingRuleType.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
- int或string转换为枚举
dto.AccountDefinition = (EnumAccountDefinition)Enum.Parse(typeof(EnumAccountDefinition), entity.AccountDefinition.ToString());
- 枚举转换为int
entity.ContraAccountDefinition = (int)dto.ContraAccountDefinition;
加小标题
加括号就会变成小标题。。。
- Grid 设置列的显示格式
grvList.Columns["InsertDate"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
grvList.Columns["InsertDate"].DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss";
设置DateFormat
grvList.DisplayFormatForDate("InsertDate");
设置MoneyFormat
grvList.DisplayFormatForMoney("Saldo");
去掉 AutoFilterRow 的编辑控件
void grvList_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
{
if (e.Column.FieldName == "ButtonColumn" && e.RowHandle != GridControl.AutoFilterRowHandle)
{
e.RepositoryItem = buttonEdit;
}
}
treeList.OptionsSelection.EnableAppearanceFocusedCell = false;