private void btnResetAllControlAllUser_Click(object sender, EventArgs e) { if (DialogResult.Yes == XtraMessageBoxHelper.ShowYesNoAndTips("您确定要清除全部控件全部用户配置?")) { GridConfigFactory.Current.DeleteAllControlAllUserConfig(); } }
private void btnResetCurrentControlDefault_Click(object sender, EventArgs e) { if (DialogResult.Yes == XtraMessageBoxHelper.ShowYesNoAndTips("您确定要清除本控件配置?")) { GridConfigFactory.Current.DeleteCurrentControlConfig(TargetGrid.GridID); } }
/// <summary> /// 设为默认设置 /// </summary> private void btnSetAsDefault_Click(object sender, EventArgs e) { if (DialogResult.Yes == XtraMessageBoxHelper.ShowYesNoAndTips("您确定要把当前设置存为默认设置吗?")) { TargetGrid.SaveConfig(Guid.Empty); } }
private void btnTemplateApple_Click(object sender, EventArgs e) { var entity = Grid.GetSelected <GridConfigTemplateEntity>(); if (entity != null) { XtraMessageBoxHelper.ShowYesNoAndTips("确定要应用模板吗?", p => GridConfigTemplateFactory.Current.LoadConfig(TargetGrid, entity.Name)); } }
protected virtual void AsDefault() { if (DialogResult.Yes == XtraMessageBoxHelper.ShowYesNoAndTips("您确定要恢复默认设置吗?")) { GridConfigFactory.Current.DeleteConfig(TargetGrid.GridID, Guid.Empty); TargetGrid.LoadConfig(); TargetGrid.IsConfigChange = false; Cancel(); } }
private void btnDelete_Click(object sender, EventArgs e) { XtraMessageBoxHelper.ShowYesNoAndWarning("确定要删除选中的数据吗?", d => { var entity = Grid.GetSelected(); if (entity != null) { Grid.Delete(entity); } }); }
private void btnAutoGenerated_Click(object sender, EventArgs e) { if (TargetGrid.EntityType == null) { XtraMessageBoxHelper.ShowWarning("没有指定表格的实体类型 EntityType"); return; } string typeName = TargetGrid.EntityType.FullName; var meta = EntityMetadataFactory.Current.Get(typeName); if (meta == null) { XtraMessageBoxHelper.ShowWarning("没有指定实体元数据"); return; } XtraMessageBoxHelper.ShowYesNoAndTips("确定自动生成列吗?", d => { TargetGrid.View.OptionsBehavior.Editable = true; TargetGrid.View.Columns.Clear(); #region 自动选择 GridColumn colSelected = new GridColumn(); colSelected.FieldName = "Selected"; colSelected.Caption = "选择"; colSelected.VisibleIndex = 0; colSelected.OptionsColumn.AllowEdit = true; colSelected.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; TargetGrid.View.Columns.Add(colSelected); #endregion for (int index = 0; index < meta.EntityFields.Count; index++) { EntityField filed = meta.EntityFields[index]; GridColumn column = new GridColumn(); column.Name = "grid_{0}_{1}".FS(typeName, filed.FieldName); column.FieldName = filed.FieldName; column.Caption = filed.FieldComment; column.VisibleIndex = index + 1; column.OptionsColumn.AllowEdit = false; var dataType = EntityMetadata.GetFastProperty(TargetGrid.EntityType, filed.FieldName).Property.PropertyType; if (dataType == typeof(DateTime) || dataType == typeof(DateTime?)) { column.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; column.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss"; } TargetGrid.View.Columns.Add(column); } Grid.RefreshData(); TargetGrid.View.BestFitColumns(); }); }
private void btnTemplateDelete_Click(object sender, EventArgs e) { var entity = Grid.GetSelected <GridConfigTemplateEntity>(); if (entity != null) { XtraMessageBoxHelper.ShowYesNoAndTips("确定要删除模板吗?", p => { GridConfigTemplateFactory.Current.DeleteConfig(entity.ID); InitData(); this.Grid.View.MoveLastVisible(); }); } }
private void btnAutoGenerated_Click(object sender, EventArgs e) { if (TargetGrid.EntityType == null) { XtraMessageBoxHelper.ShowWarning("没有指定表格的实体类型 EntityType"); return; } string typeName = TargetGrid.EntityType.FullName; var meta = EntityMetadataFactory.Current.Get(typeName); if (meta == null) { XtraMessageBoxHelper.ShowWarning("没有指定实体元数据"); return; } XtraMessageBoxHelper.ShowYesNoAndTips("确定自动生成列吗?", d => { TargetGrid.OptionsBehavior.AutoPopulateColumns = false; TargetGrid.OptionsBehavior.Editable = true; TargetGrid.Columns.Clear(); for (int index = 0; index < meta.EntityFields.Count; index++) { EntityField filed = meta.EntityFields[index]; TreeListColumn column = TargetGrid.Columns.Add(); column.Name = "tree_{0}_{1}".FS(typeName, filed.FieldName); column.FieldName = filed.FieldName; column.Caption = filed.FieldComment; column.VisibleIndex = index + 1; column.OptionsColumn.AllowEdit = false; var dataType = EntityMetadata.GetFastProperty(TargetGrid.EntityType, filed.FieldName).Property.PropertyType; if (dataType == typeof(DateTime) || dataType == typeof(DateTime?)) { column.Format.FormatType = DevExpress.Utils.FormatType.DateTime; column.Format.FormatString = "yyyy-MM-dd HH:mm:ss"; } } Grid.RefreshData(); TargetGrid.BestFitColumns(); }); }