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个回答

好久才发现,还有个帖子没人回答。
现在自行解决了,如果是要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;

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问