zwk333 2015-10-16 01:45 采纳率: 0%
浏览 2412

devexpress:画面再次载入后,bandgridview的列宽自动变长

初次进入画面或者关掉画面再打开都是正常, 每列的长度都是100. 如果按下test按钮刷新,列宽自动变长,超过100. 求助各位大侠。
![private void Form1_Load(object sender, EventArgs e)
{
GridBand band1 = new GridBand();
band1.Caption = "band1";
this.bandedGridView1.Bands.Add(band1);
GridBand band2 = new GridBand();
band2.Caption = "band2";
this.bandedGridView1.Bands.Add(band2);

        GridBand mainBand = new GridBand();
        BandedGridColumn subBand = new BandedGridColumn();
        for (int i = 0; i < this.bandedGridView1.Bands.Count; i++)
        {
            mainBand = this.bandedGridView1.Bands[i];
            if (i < 1)
            {
                subBand = new BandedGridColumn();
                subBand.Name = "col" + i;
                subBand.Caption = "colName" + i;
                subBand.FieldName = "col" + i;
                subBand.Width = 100;
                subBand.Visible = true;
                mainBand.Columns.Add(subBand);
            }
            else
            {
                for (int m = 0; m < 4; m++)
                {
                    subBand = new BandedGridColumn();
                    subBand.Name = "col" + m;
                    subBand.Caption = "colName" + m;
                    subBand.FieldName = "col" + m;
                    subBand.Width = 100;
                    subBand.Visible = true;
                    mainBand.Columns.Add(subBand);
                }
            }
        }
    }

    private void btnTest_Click(object sender, EventArgs e)
    {
        this.bandedGridView1.Bands.Clear();
        this.bandedGridView1.Columns.Clear();
        Form1_Load(sender, e);
    }
}

图片说明](https://img-ask.csdn.net/upload/201510/16/1444959958_310970.jpg)

  • 写回答

1条回答 默认 最新

  • zwk333 2015-10-26 05:46
    关注

    好久才发现,还有个帖子没人回答。
    现在自行解决了,如果是要bandview的方式来展现图片中效果,可以用下列方式来实现:
    第1列
    GridBand mainBand = new GridBand();
    第2列
    GridBand subMainband = new GridBand();
    要实现band2列的效果,可参考下行代码
    mainBand.Children.Add(subMainband);
    第3列
    BandedGridColumn subBand = new BandedGridColumn();
    第3列一般是隐藏的,只用于绑定datatable时用。
    this.bandedGridView1.OptionsView.ShowColumnHeaders = false;

    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?