.net 组件使用求助

visual_alan 2007-05-08 09:00:27
express .net 组件中,xtragrid中如何使grouprow和数据行一样,出现列格.
现在grouprow是这样:
列1 列2 列3
- 部门 (sum=1111)
1 1 1

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



...全文
430 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wedobest2008 2007-05-21
  • 打赏
  • 举报
回复
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;
}
在你说的那个组件的公司的开发论坛上找到的,自己多找找,何必这么求人
visual_alan 2007-05-15
  • 打赏
  • 举报
回复
up
visual_alan 2007-05-14
  • 打赏
  • 举报
回复
up
visual_alan 2007-05-10
  • 打赏
  • 举报
回复
楼上的说得有对,我把这些自定义事件都看了,可以自定义分组统计规则和显示内容了,但像数据行一样的显示格式怎么弄还是没弄出来。
可否再详细些,或在指条明路啊
visual_alan 2007-05-08
  • 打赏
  • 举报
回复
是不是没说清楚
xiyun 2007-05-08
  • 打赏
  • 举报
回复
估计得自己处理customor...的事件了吧。我现在手头上没有这个控件,查不了。估计可以作,但麻烦点,自己写代码处理,没有现成的
visual_alan 2007-05-08
  • 打赏
  • 举报
回复
up

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧