开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 5812|回复: 3

【求助】gridcontrol列宽设置无效

[复制链接]

0

精华

47

贡献

231

赞扬

帖子
116
软币
2603
在线时间
240 小时
注册时间
2013-6-9
发表于 2013-10-16 22:09:45 | 显示全部楼层 |阅读模式
如下图:
001.jpg
代码如下:
string sql = "SELECT ltrim(rtrim(gzxm )) as 工资项目 ,ltrim(rtrim(xmlx)) as 项目类型 ,ltrim(rtrim(xsws)) as 小数位数 ,ltrim(rtrim(swfs)) as 舍位方式 ,ltrim(rtrim(init)) as 初始值 ,ltrim(rtrim(isshow)) as 是否显示 ,ltrim(rtrim(Formula)) as 计算公式 ,ltrim(rtrim(ztname))  as 所属帐套 from 工资项目 where ztname='" + see + "'";
                //MessageBox.Show(sql);
                DataSet ds2 = Maticsoft.DBUtility.DbHelperSQL.DateSetQuery(sql);
                DataTable dt2 = new DataTable();
                dt2 = ds2.Tables[0];
                gridControl2.DataSource = dt2;
                gridView2.BestFitColumns();
                this.gridView2.Columns["工资项目"].Width = 20;
                this.gridView2.Columns["项目类型"].Width = 20;
                this.gridView2.Columns["小数位数"].Width = 15;
                this.gridView2.Columns["舍位方式"].Width = 20;
                this.gridView2.Columns["初始值"].Width = 20;
                this.gridView2.Columns["是否显示"].Width = 10;
                this.gridView2.Columns["计算公式"].Width = 40;
                this.gridView2.Columns["所属帐套"].Width = 30;
请各位帮忙看一下
回复

使用道具 举报

0

精华

10

贡献

18

赞扬

帖子
27
软币
491
在线时间
54 小时
注册时间
2013-7-5
QQ
发表于 2013-10-17 11:15:13 | 显示全部楼层
根据你所描述的问题,devexpress中的gridControl控件默认是自动列宽的,所以建议你gridview右键属性里面设置ColumnAutoWidth设置为false,这个问题应该可以解决。
回复

使用道具 举报

0

精华

52

贡献

93

赞扬

帖子
90
软币
2314
在线时间
167 小时
注册时间
2013-6-8
QQ
发表于 2013-10-18 18:07:32 | 显示全部楼层
gridView2.BestFitColumns();
有这个就行了
回复

使用道具 举报

0

精华

47

贡献

231

赞扬

帖子
116
软币
2603
在线时间
240 小时
注册时间
2013-6-9
 楼主| 发表于 2013-10-18 20:50:37 | 显示全部楼层
谢谢二位兄弟,发现问题了,字段设置的问题
回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-5-9 08:20

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表