GridControl
===============1、禁止编辑========================================
1.1 这个是整个表格都不可编辑
gridView1.OptionsBehavior.Editable = false;
1.2 这个是某列不可编辑,gridColumn1你不想让编辑的列可以是gridColumn1,gridColumn2,gridColumn3 自己根据情况设置就好了
gridColumn1.OptionsColumn.AllowEdit = false;
1.3 这是某行某列禁止编辑
private void gvSAPPlan_ShowingEditor(object sender, CancelEventArgs e)
{
if (paperPA1052DtoBindingSource.Current is PaperPA1052Dto current && current != null)
{
if (current.CZspzt == PaperPlanConst.Spzt_Y) e.Cancel = true;
}
}
==============2、编辑框及转义==========================================
2.1 自定义控件
collnr1.ColumnEdit = columnEdit;
var widget = new SearchPopupWidget(keywords =>
{
var list = xxxx.Proxy.Query(Plant, keywords)
.Select(x => new ValueDisplayItem
{
DisplayName = x.txt,
Value = x.lnr,
Tag = x
}).ToList();
return list;
});
var columnEdit = widget.CreateRepositoryItemButtonEdit(x =>
{
var row = this.bscXXX.Current as xxxDto;
row.lnr = x.Value;
row.lnrName = x.DisplayName;
this.gvXxxx.BestFitColumns();
});
2.2 自定义转义内容
CustomColumnDisplayText 事件e.Column.Name
this.colXxxx.ColumnEdit = WidgetsHelper.GetRepositoryItemImageComboBox(new object[] { "F", "未发", "Y", "已发" });
2.2 同步行选择
同步行选择状态到checkbox选择列(selected_column)
ViewControl.Config(gcXXX).AllowSyncRowStateToCheckboxSelection = true;
底部汇总
GridView->FooterPanel
OptionsView:ShowFooter=true
Columns->SummaryItem->SummaryType = Sum
数:{0} Count
长 SUM={0:0.##}
重量 SUM={0:0.##}
剩余重量 SUM={0:0.##}
gdvNew.Focus(); //GridControl 控件获取焦点
gdvNew.FocusedRowHandle = _smtReport.Count - 1; //设置焦点行
gdvNew.FocusedColumn = gdvNew.Columns[0];//设置焦点单元格
获取选中行某列的值
int selectedHandle;
selectedHandle = this.gridView1.GetSelectedRows()[0];
MessageBox.Show(this.gridView1.GetRowCellValue(selectedHandle, "RoadName").ToString());
获得选中行的单元格的值(注:“RoadName”代表属性字段)