请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册

QQ登录

只需一步,快速开始

xjsxjs197
论坛元老   /  发表于:2014-3-7 09:22  /   查看:5490  /  回复:6
当某些列的数据过长,通过设置Grid的属性,可以让显示不下的数据显示成例如: 【西安葡萄城技术...】的形式。
问题是Grid能否判断出当前的数据是否显示不全?
GetDataDisplay方法返回的是完整的数据,而不是【西安葡萄城技术...】形式的数据。

谢谢。

6 个回复

倒序浏览
roger.wang
社区贡献组   /  发表于:2014-3-7 10:23:00
沙发
回复 1楼xjsxjs197的帖子

xjsxjs197 你好,
请问你使用的是 TrueDBG日的、 吗?可以通过 this.c1TrueDBGrid1[row,col] 形式来获取单元格value。
回复 使用道具 举报
xjsxjs197
论坛元老   /  发表于:2014-3-7 11:29:00
板凳
不好意思,没明白你的意思。
比如我的Grid名称: myGrid. 你是说使用: this.myGrid[row, col]的形式吗?我试了,不行,还是原来的完整的值。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-3-7 13:04:00
地板
回复 3楼xjsxjs197的帖子

问题我这边已经查收,正在调查中。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-3-12 10:18:00
5#
回复 1楼xjsxjs197的帖子

抱歉,请问“【西安葡萄城技术...】的形式”是否是通过 “OwnerDrawCell”来实现的?
以下是 TrueDBGrid 的实现代码,FlexGrid 实现形式相同

  1. void c1TrueDBGrid1_OwnerDrawCell(object sender, C1.Win.C1TrueDBGrid.OwnerDrawCellEventArgs e)
  2. {
  3.   e.Handled = true;
  4.   e.Graphics.FillRectangle(new SolidBrush(e.Style.BackColor), e.CellRect);
  5.   object val = c1TrueDBGrid1.Columns[e.Col].CellValue(e.Row);
  6.   SizeF size = e.Graphics.MeasureString(val.ToString(), c1TrueDBGrid1.Splits[0].DisplayColumns[e.Col].Style.Font);
  7.   int width = (int)Math.Ceiling(size.Width);
  8.   int cellwidth = e.CellRect.Width;
  9.   if (width > cellwidth)
  10.   {
  11.     int r = 1;
  12.     string s = e.Text;
  13.     string ns = "";
  14.     while (width > cellwidth - 5)
  15.     {
  16.       ns = s.Substring(0, s.Length - r);
  17.       size = e.Graphics.MeasureString(ns.ToString(), c1TrueDBGrid1.Splits[0].DisplayColumns[e.Col].Style.Font);
  18.       width = (int)Math.Ceiling(size.Width);
  19.       r++;
  20.       s = ns;
  21.     }
  22.     ns = ns + "....";
  23.     e.Graphics.DrawString(ns, e.Style.Font, new SolidBrush(Color.Black), new PointF(e.CellRect.X, e.CellRect.Y));
  24.    }
  25.    else
  26.    {
  27.      e.Graphics.DrawString(e.Text, e.Style.Font, new SolidBrush(Color.Black), new PointF(e.CellRect.X, e.CellRect.Y));
  28.    }
  29. }
复制代码


如果是这样,只能通过代码来重新拼写字符串实现。也就是再做一次事件中的判断。
回复 使用道具 举报
xjsxjs197
论坛元老   /  发表于:2014-3-12 13:29:00
6#
好的,了解,非常感谢!
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-3-12 13:38:00
7#
回复 6楼xjsxjs197的帖子

不客气,应该做的
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部