1

我有一个 ultrawingrid,我在其中设置运行时的列数。超网格的属性设置为 dock.fill。它也在带有rowlayout的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
4

1 回答 1

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;
        }
    }
}
于 2012-11-14T12:15:34.800 回答