列边界在Telerik Grid中为Winforms重叠

时间:2015-03-31 12:34:09

标签: c# windows winforms telerik telerik-grid

enter image description here

我正在研究Winform应用程序。在其上使用Telerik控件。

在1表单上,我需要有复合列,如上图所示。这些列已经动态添加(通过C#),我使用了HTMlViewDefinition。

问题是,列边界重叠,如上图所示。

我需要在运行时决定列宽,因此不要给它们提供静态宽度。

注意:由于机密性,我从快照中删除了列名,并在代码中放置了虚拟列名。希望不是问题。

真诚地感谢任何帮助。提前致谢

代码,我为此网格编写如下

var htmlView = new HtmlViewDefinition()
                {

                };
                htmlView.RowTemplate.Rows.Add(new RowDefinition());
                htmlView.RowTemplate.Rows.Add(new RowDefinition());

                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("No"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col1"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col2"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col3"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col4"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col5"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col6"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col7"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col8"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col9"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col10"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col11"));

                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col12"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col13"));


                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col14"));
                htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Col15"));

  htmlView.RowTemplate.Rows[0].Cells[0].RowSpan = 2;
                htmlView.RowTemplate.Rows[0].Cells[3].RowSpan = 2;
                htmlView.RowTemplate.Rows[0].Cells[4].RowSpan = 2;

                htmlView.RowTemplate.Rows[0].Cells[3].ColSpan = 1;
                htmlView.RowTemplate.Rows[0].Cells[4].ColSpan = 1;

                htmlView.RowTemplate.Rows[0].Cells[5].RowSpan = 2;
                htmlView.RowTemplate.Rows[0].Cells[6].RowSpan = 2;
                htmlView.RowTemplate.Rows[0].Cells[7].RowSpan = 3;


 htmlView.RowTemplate.Rows[0].Cells[9].RowSpan = 2;
                htmlView.RowTemplate.Rows[0].Cells[10].RowSpan = 2;
                htmlView.RowTemplate.Rows[0].Cells[11].RowSpan = 2;
                htmlView.RowTemplate.Rows[0].Cells[12].RowSpan = 2;
                htmlView.RowTemplate.Rows[0].Cells[13].RowSpan = 2;

                htmlView.RowTemplate.Rows[0].Cells[14].RowSpan = 2;
                htmlView.RowTemplate.Rows[0].Cells[15].RowSpan = 2;


 htmlView.RowTemplate.Rows[0].Height = 30;

                htmlView.RowTemplate.Rows[1].Cells.Add(new CellDefinition("Item Description"));
                htmlView.RowTemplate.Rows[1].Cells[0].ColSpan = 2;
                htmlView.RowTemplate.Rows[1].Cells.Add(new CellDefinition("Direction"));
 htmlView.RowTemplate.Rows[1].Height = 30;
 gridDrugList.BestFitColumns();

                gridDrugList.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

 gridDrugList.ViewDefinition = htmlView;

1 个答案:

答案 0 :(得分:1)

这似乎是带有Html视图定义的known issue。建议的解决方法是订阅RadGridView的SizeChanged事件并刷新行:

  private void RadGridView1_SizeChanged(object sender, EventArgs e)
  {
      radGridView1.TableElement.ViewElement.UpdateRows(true);
  }