找回密码
 立即注册

QQ登录

只需一步,快速开始

hlm750908

注册会员

3

主题

8

帖子

29

积分

注册会员

积分
29

微信认证勋章

最新发帖
hlm750908
注册会员   /  发表于:2017-5-10 11:51  /   查看:3430  /  回复:7
cell的列 key 也 要用数字
sv.Cells[4, 0].CellType = imgType5;

设计的时候必须数准那一列 对应 什么数据
而不能用
sh3.Columns["sfb86"].Width = 90;
这样的方式
大家也是这样用的吗

7 个回复

倒序浏览
hlm750908
注册会员   /  发表于:2017-5-10 11:53:35
沙发
sv.Cells[4, “sfb86”].CellType = imgType5;  这样的方式比较舒服
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-5-10 18:20:18
板凳
您可以自己维护一个name和 col Index 的对应关系,一个key value  list就可以。
回复 使用道具 举报
hlm750908
注册会员   /  发表于:2017-5-12 08:21:27
地板
那不爽  这个连微软的 datagridview 都 是标准风格的用法
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-5-12 12:27:40
5#
这个不支持
回复 使用道具 举报
hlm750908
注册会员   /  发表于:2017-5-15 09:42:44
6#
本帖最后由 hlm750908 于 2017-5-15 09:44 编辑

最终用这么一个类搞定了
class lastinfo
    {
        public string SFB86 { get; set; }  // 上阶工单
        public string SFA01 { get; set; }  // 排产工单
        public string SFA03 { get; set; }  // 料号
        public string SFA26 { get; set; }  // 替代码
        public string SFA12 { get; set; }  // 发料单位
        public string SFA05 { get; set; }  // 应发量
        public string SFA06 { get; set; }  // 已发量
        public string QTY { get; set; }  // 滚动累计
        public string ALLQTY { get; set; }  // 可用量合计
        public string OK { get; set; }  // 余量
        public string IMG10 { get; set; }  // 库存量
        public string IQC { get; set; }  // IQC量
        public string DUONA { get; set; }  // 多拿料
        public string SN { get; set; }  // 优先度
        public string RN { get; set; }  // 顺序
        public class x
        {
            public static int 上阶工单 = 0;//
            public static int 排产工单 = 1;//
            public static int 料号 = 2;//
            public static int 替代码 = 3;//
            public static int 发料单位 = 4;//
            public static int 应发量 = 5;//
            public static int 已发量 = 6;//
            public static int 滚动累计 = 7;//
            public static int 可用量合计 = 8;//
            public static int 余量 = 9;//
            public static int 库存量 = 10;//
            public static int IQC量 = 11;//
            public static int 多拿料 = 12;//
            public static int 优先度 = 13;//
            public static int 顺序 = 14;//            
        }    }

然后 列头设定
            sh3.ColumnHeader.Columns[lastinfo.x.上阶工单].Label = "上阶工单";
            sh3.ColumnHeader.Columns[lastinfo.x.排产工单].Label = "排产工单";
            sh3.ColumnHeader.Columns[lastinfo.x.料号].Label = "料号";
            sh3.ColumnHeader.Columns[lastinfo.x.替代码].Label = "替代码";
            sh3.ColumnHeader.Columns[lastinfo.x.发料单位].Label = "发料单位";
            sh3.ColumnHeader.Columns[lastinfo.x.应发量].Label = "应发量";
            sh3.ColumnHeader.Columns[lastinfo.x.已发量].Label = "已发量";
            sh3.ColumnHeader.Columns[lastinfo.x.滚动累计].Label = "滚动累计";
            sh3.ColumnHeader.Columns[lastinfo.x.可用量合计].Label = "可用量合计";
            sh3.ColumnHeader.Columns[lastinfo.x.余量].Label = "余量";
            sh3.ColumnHeader.Columns[lastinfo.x.库存量].Label = "库存量";
            sh3.ColumnHeader.Columns[lastinfo.x.IQC量].Label = "IQC量";
            sh3.ColumnHeader.Columns[lastinfo.x.多拿料].Label = "多拿料";
            sh3.ColumnHeader.Columns[lastinfo.x.优先度].Label = "优先度";
            sh3.ColumnHeader.Columns[lastinfo.x.顺序].Label = "顺序";
回复 使用道具 举报
hlm750908
注册会员   /  发表于:2017-5-15 09:50:42
7#
数据填充的代码
int startrow = sh3.Rows.Count;
                sh3.Rows.Add(sh3.Rows.Count, list.Count);

                foreach (var o in list)
                {

                    sh3.Cells[startrow, lastinfo.x.上阶工单].Value = o.SFB86;//
                    sh3.Cells[startrow, lastinfo.x.排产工单].Value = o.SFA01;//
                    sh3.Cells[startrow, lastinfo.x.料号].Value = o.SFA03;//
                    sh3.Cells[startrow, lastinfo.x.替代码].Value = o.SFA26;//
                    sh3.Cells[startrow, lastinfo.x.发料单位].Value = o.SFA12;//
                    sh3.Cells[startrow, lastinfo.x.应发量].Value = o.SFA05;//
                    sh3.Cells[startrow, lastinfo.x.已发量].Value = o.SFA06;//
                    sh3.Cells[startrow, lastinfo.x.滚动累计].Value = o.QTY;//
                    sh3.Cells[startrow, lastinfo.x.可用量合计].Value = o.ALLQTY;//
                    sh3.Cells[startrow, lastinfo.x.余量].Value = o.OK;//
                    sh3.Cells[startrow, lastinfo.x.库存量].Value = o.IMG10;//
                    sh3.Cells[startrow, lastinfo.x.IQC量].Value = o.IQC;//
                    sh3.Cells[startrow, lastinfo.x.多拿料].Value = o.DUONA;//
                    sh3.Cells[startrow, lastinfo.x.优先度].Value = o.SN;//
                    sh3.Cells[startrow, lastinfo.x.顺序].Value = o.RN;//

                    startrow++;
                }
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-5-15 09:50:47
8#
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部