Complete gridview with empty rows

4 posts, 0 answers
  1. Lookoum
    Lookoum avatar
    7 posts
    Member since:
    Nov 2011

    Posted 01 Dec 2011 Link to this post

    Hi everybody,

    I would like to know if it is possible to complete a gridview  with empty rows?

    For example, I have a grid view which can contain 9 rows but I only have 3 items to show.
    The bottom of my grid is empty and I'd prefer having empty rows than nothing!

    How can I do this?

    Thanks

    Lookoum
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 02 Dec 2011 Link to this post

    Hello Laffargue,

    For this scenario you can use RadGridView in unbound mode. Set you number of rows and columns and fill only rows that must contain values. Here is a simple example:

    radGridView1.RowCount = 9;
    radGridView1.ColumnCount = 5;
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < radGridView1.ColumnCount; j++)
        {
            radGridView1.Rows[i].Cells[j].Value = "MyValue";
        }
         
    }

    I hope this helps. Let me know if you need further assistance.

    Best wishes,
    Julian Benkov
    the Telerik team

    Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

  3. Lookoum
    Lookoum avatar
    7 posts
    Member since:
    Nov 2011

    Posted 05 Dec 2011 Link to this post

    Hi Mr Benkov,

    Thanks for your answer but my RadGridView is filled by my database.
    I used the FiledName properties in order to bind values.
    Isn't it posssible to complete the grid automatically?

    I think maybe there's a problem when I group my data by a column.

    I would like to complete my grid cause I use the alternatingrowscolors properties  (blue and gray) and I don't want to see some blank on the bottom of the grid if this one is not complete.

    Thank you.

    Lookoum

  4. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 08 Dec 2011 Link to this post

    Hello Laffargue,

    I understand your requirements. The RadGridView control does not support this functionality - to mix bound and unbound rows to render alternating row colors. The solution in this situation is to add dummy empty rows in your data source, but the synchronization will be more complex if you apply sorting, filtering, grouping operations.

    Do not hesitate to contact us if you have further questions or issues.

    Regards,
    Julian Benkov
    the Telerik team

    Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Back to Top