質問

I have a ultrawingrid in which I am setting the number of columns at runtime. The ultragrid has property set to dock.fill. Also it is in cardview with rowlayout. If there are more than 5 columns I want the wingrid to show next 5 columns in next row and so on until the end of the row so that I do not have to display a horizontal scrollbar and all the fields are visible.

eg.

 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
役に立ちましたか?

解決

A class to set the column positions. The grids name is filtergrid. Other things are almost explanatory. We only declared the grid in design (For some reason, which we don't know, we were not able to use this function when we declared the grid inside the code). All other settings were done in code.

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;
        }
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top