【问题标题】:Column Boundaries getting overlapped in Telerik Grid for WinformsTelerik Grid for Winforms 中的列边界重叠
【发布时间】:2015-03-31 12:34:08
【问题描述】:

我正在开发 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;

【问题讨论】:

  • 如果您可以包含更多代码 - 特别是您定义 RadGridView 的代码(假设这是 gridDrugList 的代码) - 那么我可能会提供帮助。就目前的代码而言,当我运行您包含的代码时,我得到“没有数据显示”。因此,我可能还需要一些虚拟数据来放入您的代码中。另一个想法,我相信您已经尝试过,是删除 BestFitColumns() 行和 AutoSizeColumnsMode 行。

标签: c# windows winforms telerik telerik-grid


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-03
    • 1970-01-01
    • 1970-01-01
    • 2014-03-20
    • 1970-01-01
    相关资源
    最近更新 更多