void menuItem_Click(object sender, EventArgs e) { ToolStripMenuItem menuItem = (ToolStripMenuItem)sender; menuItem.Checked = !menuItem.Checked; foreach (GridColumn column in ((ColumnView)MainView).Columns) { if (column.GetCaption() == menuItem.Text) { column.Visible = menuItem.Checked; if (column.Visible) { column.VisibleIndex = menuItem.Owner.Items.IndexOfKey(menuItem.Name); } this.Refresh(); return; } } PropertyInfo objPropertyInfo = (PropertyInfo)menuItem.Tag; GridColumn col = ((ColumnView)MainView).Columns.AddField(objPropertyInfo.Name); object[] attValues = objPropertyInfo.GetCustomAttributes(typeof(CaptionColumn), false); if (attValues.Length > 0 && attValues[0] is CaptionColumn) { col.Caption = (attValues[0] as CaptionColumn).Caption; } else { col.Caption = col.GetCaption(); } attValues = objPropertyInfo.GetCustomAttributes(typeof(XtraGridEditor), false); if (attValues.Length > 0 && attValues[0] is XtraGridEditor) { if ((attValues[0] as XtraGridEditor).RepositoryItem == typeof(RepositoryItemCheckEdit)) { CheckBoxEditor.Name = (attValues[0] as XtraGridEditor).Name; col.ColumnEdit = CheckBoxEditor; } else if ((attValues[0] as XtraGridEditor).RepositoryItem == typeof(RepositoryItemLookUpEdit)) { LookUpEditor.Name = (attValues[0] as XtraGridEditor).Name; col.ColumnEdit = LookUpEditor; } } col.Width = col.GetBestWidth(); col.Visible = true; col.VisibleIndex = ContextMenuStrip.Items.IndexOf(menuItem); menuItem.Text = col.GetCaption(); }
void ShowCaptionEditor(GridColumn column) { GridViewInfo vi = gridView.GetViewInfo() as GridViewInfo; Rectangle bounds = vi.ColumnsInfo[column].Bounds; bounds.Width -= 3; bounds.Height -= 3; bounds.Y += 3; headerEdit.BackColor = GetColor(); headerEdit.SetBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height); headerEdit.EditValue = column.GetCaption(); headerEdit.Show(); headerEdit.Focus(); }
protected string GetTextCaptionForPrinting(GridColumn column) { if (View == null) { return(column.Caption); } var gview = View.OptionsPrint as GridOptionsPrint; if (gview != null && !gview.AllowMultilineHeaders) { return(column.GetTextCaption()); } return((View as MyGridView).GoAndGetNonFormattedCaption(column.GetCaption())); }
private void DoAutoFill() { int length = CaptionItems.Length + View.Columns.Count; List <CaptionItem> captions = new List <CaptionItem>(); captions.AddRange(CaptionItems); for (int i = 0; i < View.Columns.Count; i++) { GridColumn column = View.Columns[i]; captions.Add(new CaptionItem() { FieldName = column.FieldName, Captions = column.GetCaption() + SEPARATOR_STRING }); } CaptionItems = captions.ToArray(); }
private void gridView1_CustomSummaryCalculate(object sender, DevExpress.Data.CustomSummaryEventArgs e) { GridView view = sender as GridView; if (e.Item != titleItem) { return; } if (e.SummaryProcess != DevExpress.Data.CustomSummaryProcess.Finalize) { return; } GridColumn col = view.GroupedColumns[e.GroupLevel]; object value = view.GetGroupRowValue(e.GroupRowHandle); e.TotalValue = string.Format("Totale {0} {1}", col.GetCaption(), value); }
private int GetColumnBestHeight(GridViewInfo viewInfo, GridColumn column) { GridColumnInfoArgs ex = viewInfo.ColumnsInfo[column]; if (ex == null) { viewInfo.GInfo.AddGraphics(null); ex = new GridColumnInfoArgs(viewInfo.GInfo.Cache, null); try { ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(), new GlyphElementInfoArgs(viewInfo.View.Images, 0, null), StringAlignment.Near)); if (viewInfo.View.CanShowFilterButton(null)) { ex.InnerElements.Add(viewInfo.Painter.ElementsPainter.FilterButton, new GridFilterButtonInfoArgs()); } ex.SetAppearance(viewInfo.PaintAppearance.HeaderPanel); ex.Caption = column.Caption; ex.CaptionRect = new Rectangle(0, 0, column.Width - 20, 17); } finally { viewInfo.GInfo.ReleaseGraphics(); } } GraphicsInfo grInfo = new GraphicsInfo(); grInfo.AddGraphics(null); ex.Cache = grInfo.Cache; bool canDrawMore = true; Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.GetCaption()); Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore); res.Height = Math.Max(res.Height, captionSize.Height); res.Width += captionSize.Width; res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size; grInfo.ReleaseGraphics(); return res.Height; }
private int GetColumnBestHeight(GridViewInfo viewInfo, GridColumn column, int height) { GridColumnInfoArgs ex = viewInfo.ColumnsInfo[column]; if (ex == null) { viewInfo.GInfo.AddGraphics(null); ex = new GridColumnInfoArgs(viewInfo.GInfo.Cache, null); try { ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(), new GlyphElementInfoArgs(viewInfo.View.Images, 0, null), StringAlignment.Near)); if (viewInfo.View.CanShowFilterButton(null)) { ex.InnerElements.Add(viewInfo.Painter.ElementsPainter.FilterButton, new GridFilterButtonInfoArgs()); } ex.SetAppearance(viewInfo.PaintAppearance.HeaderPanel); ex.Caption = column.Caption; ex.CaptionRect = new Rectangle(0, 0, column.Width - 20, 17); } finally { viewInfo.GInfo.ReleaseGraphics(); } } GraphicsInfo grInfo = new GraphicsInfo(); grInfo.AddGraphics(null); ex.Cache = grInfo.Cache; bool canDrawMore = true; Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.GetCaption()); Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore); //res.Height = Math.Max(res.Height, captionSize.Height); res.Height = height; res.Width += captionSize.Width; //res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size; //res =new Size(180, 33); grInfo.ReleaseGraphics(); return(res.Height); }
private int GetColumnBestHeight(GridViewInfo viewInfo, GridColumn column) { GridColumnInfoArgs ex = viewInfo.ColumnsInfo[column]; GraphicsInfo grInfo = new GraphicsInfo(); grInfo.AddGraphics(null); ex.Cache = grInfo.Cache; bool canDrawMore = true; Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.GetCaption()); Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore); res.Height = Math.Max(res.Height, captionSize.Height); res.Width += captionSize.Width; res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size; grInfo.ReleaseGraphics(); return(res.Height); }