ultragrid:如果超过一定数量,则在下一行显示一些列

时间:2012-09-17 06:34:20

标签: infragistics ultragrid ultrawingrid

我有一个ultrawingrid,我在运行时设置列数。 ultragrid的属性设置为dock.fill。它也是在rowviewout的cardview中。如果有超过5列,我希望wingrid在下一行显示接下来的5列,依此类推直到行的末尾,这样我就不必显示水平滚动条,所有字段都可见。

例如。

 Now they are arranged as
| Column1 | text | Column2 | text | Column3 | text | Column4 | text | Column5 | text |
and a scrollbar appears if they move beyond the right boundary.
Instead I want it to show only 3 columns in first row then the others in next row and so on.
No scrollbars.
I have only 1 card and only 1 row.code here

1 个答案:

答案 0 :(得分:0)

用于设置列位置的类。网格名称是filtergrid。其他事情几乎是解释性的。我们只在设计中声明了网格(出于某种原因,我们不知道,当我们在代码中声明网格时,我们无法使用此函数)。所有其他设置均在代码中完成。

const int NoOfCols = 7;
private void SetDefaultColumnPositions(RowLayoutColumnInfosCollection colInfos)
{
    int totalColWidth = 0;
    int visibleColumnCount = 0;
    foreach (RowLayoutColumnInfo rlColInfo in colInfos)
    {
        if (rlColInfo.Column.Hidden == false)
        {
            visibleColumnCount++;
            totalColWidth += rlColInfo.Column.CellSizeResolved.Width;
        }
    }
    int NO_OF_ROWS = Convert.ToInt32(System.Math.Ceiling(visibleColumnCount * 1.0 / NoOfCols));
    int columnCount = 0;
    _filterGrid.Height = 22 * (NO_OF_ROWS);
    if (columnCount == colInfos.Count)
    {
        return;
    }
    for (int i = 0; i < NO_OF_ROWS; i++)
    {
        for (int j = 0; j < NoOfCols; j++)
        {
            if (columnCount >= colInfos.Count)
            {
                return;
            }
            while (colInfos[columnCount].Column.Hidden)
            {
                ++columnCount;
                if (columnCount >= colInfos.Count)
                {
                    return;
                }
            }
            if (columnCount < colInfos.Count)
            {
                colInfos[columnCount].Initialize((j +2) * 2, i * 2);
                ++columnCount;
            }
            if (columnCount >= colInfos.Count)
            {
                break;
            }
        }
        if (columnCount >= colInfos.Count)
        {
            break;
        }
    }
}