自定义报表怎样能让每一列自动适应大小
自定义报表怎样能让每一列自动适应大小 附件 您好,您的问题我们已经收到。由于验证需要时间,我们会在明天给您回复。 有答案了吗 您好,
动态设置列宽,需要根据显示的列的数量计算列的Width 和Position 值,如显示N列,N列的总宽度为width,则列宽可计算为:Column.Width=Column.width*(this.PrintWidth / width) ,再根据每一列宽修改对应的Position 坐标。
代码如下:
for (int c = 0; c < cols.Count; c++)
{
headers.Width = headers.Width * (this.PrintWidth / width);
cols.Width = headers.Width;
// 设置控件坐标
if (tmp == null)
{
// 设置需要显示的第一列坐标
headers.Location = new PointF(0, headers.Location.Y);
cols.Location = new PointF(headers.Location.X, cols.Location.Y);
}
else
{
// 设置需要显示的非第一列坐标,应该为前一列坐标加上宽度
headers.Location = new PointF(tmp.Location.X + tmp.Width, headers.Location.Y);
cols.Location = new PointF(headers.Location.X, cols.Location.Y);
}
} 有完整一点的实例吗 你说的这个是设置列的宽度,每一列的宽度都是一样的吧?我说的是让报表的每一列的宽度自己去适应所显示的数据的宽度哦,就像图中的,每一列的宽度都是不一样的,根据数据的长度去改变列的宽度 您好,列宽无法实现自适应设置,需要自己根据字段的长度来进行计算。
页:
[1]