日期:2014-05-19  浏览次数:20922 次

.net 组件使用求助
express   .net   组件中,xtragrid中如何使grouprow和数据行一样,出现列格.
现在grouprow是这样:
      列1         列2           列3
-   部门   (sum=1111)
      1             1                 1

可不可以这样:
      列1         列2           列3
-     部门                     1111  
      1             1                 1





------解决方案--------------------
估计得自己处理customor...的事件了吧。我现在手头上没有这个控件,查不了。估计可以作,但麻烦点,自己写代码处理,没有现成的
------解决方案--------------------
private void gridViewByDept_CustomDrawGroupRow(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e)
{
GridView view = sender as GridView;
GridGroupRowInfo groupRowInfo = e.Info as GridGroupRowInfo;

// extract summary items
ArrayList items = new ArrayList();
foreach(GridSummaryItem si in view.GroupSummary)
if(si is GridGroupSummaryItem && si.SummaryType != SummaryItemType.None)
items.Add(si);
if(items.Count == 0) return;

// draw group row without summary values
DevExpress.XtraGrid.Drawing.GridGroupRowPainter painter;
DevExpress.XtraGrid.Views.Grid.ViewInfo.GridGroupRowInfo info;
painter = e.Painter as DevExpress.XtraGrid.Drawing.GridGroupRowPainter;
info = e.Info as DevExpress.XtraGrid.Views.Grid.ViewInfo.GridGroupRowInfo;
int level = view.GetRowLevel(e.RowHandle);
int row = view.GetDataRowHandleByGroupRowHandle(e.RowHandle);
info.GroupText = view.GroupedColumns[level].Caption + ": " + view.GetRowCellDisplayText(row, view.GroupedColumns[level]);
e.Appearance.DrawBackground(e.Cache, info.Bounds);
painter.ElementsPainter.GroupRow.DrawObject(info);

// draw summary values aligned to columns
Hashtable values = view.GetGroupSummaryValues(e.RowHandle);
foreach(GridGroupSummaryItem item in items)
{
// obtain column rectangle
GridColumn column = view.Columns[item.FieldName];
Rectangle rect = GetColumnBounds(groupRowInfo.ViewInfo,column);
if(rect.IsEmpty) continue;

// calculate summary text and boundaries
string text = item.GetDisplayText(values[item], false);
SizeF sz = e.Appearance.CalcTextSize(e.Cache, text, rect.Width);
int width = Convert.ToInt32(sz.Width) + 1;
rect.X += rect.Width - width - 2;
rect.Width = width;
rect.Y = e.Bounds.Y;
rect.Height = e.Bounds.Height - 2;

// draw a summary values
e.Appearance.DrawString(e.Cache, text, rect);
}

// disable default painting of the group row
e.Handled = true;
}
在你说的那个组件的公司的开发论坛上找到的,自己多找找,何必这么求人