Dev屬性設置
阿新 • • 發佈:2017-09-15
auto express 字段寬度 else svi inf style con ffice
DisplayFormat 設置顯示格式如:{0:P}表示顯示為百分號模式。如數據源中為0.5。表示出來為50%
2、GridContro總合計及分組合計:
常規總合計直接RunDesigner-Group Summary Items
DisplayFormat 設置顯示格式如:{0:P}表示顯示為百分號模式。如數據源中為0.5。表示出來為50%
FieldName 設置顯示的對應列
ShowInGroupColumnFooter 在那一列下面顯示
SummaryType 合計方式。選擇Custom表示自定義。CustomSummaryCalculate事件可處理
//Footer行自定義列合計 GridView view = sender asGridView; if (e.Item == view.Columns["RateZk"].SummaryItem) { decimal x = Convert.ToDecimal(view.Columns["RetailFAmount"].SummaryItem.SummaryValue); decimal y = Convert.ToDecimal(view.Columns["RetailAmount"].SummaryItem.SummaryValue); view.Columns["RateZk"].SummaryItem.DisplayFormat = "{0:P}"; ) e.TotalValue = x / y; else e.TotalValue = ; }
GridContro導出Excel操作:
SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = "導出Excel"; saveFileDialog.Filter = "Excel文件(*.xls)|*.xls"; DialogResult dialogResult = saveFileDialog.ShowDialog(this);if (dialogResult == DialogResult.OK) { this.gvbrowse.OptionsPrint.AutoWidth = false; //設置導出的Excel自動調整列寬,列寬和控件的列寬一致 this.gcbrowse.ExportToXls(saveFileDialog.FileName); //this.gcbrowse.ExportToXlsOld(saveFileDialog.FileName);//這個方法默認會自動調整列寬,但是office10以上版本有的會報錯 DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.gvbrowse.OptionsPrint.AutoWidth = true; }
GridControl列要顯示百分號:
Run Designer-Columns列 FormatType="Numeric" FormatString="p"
自動調整所有字段寬度 this.gridView1.BestFitColumns();
顯示滾動條:gridView1.OptionsView.ColumnAutoWidth屬性是true,即各列的寬度自動調整,你把它設成false,就會出現了。
設置奇、偶行交替顏色
OptionsView.EnableAppearanceEvenRow =
true;
OptionsView.EnableAppearanceOddRow =
true
;
Dev屬性設置