How to change the indent for rows after .Relations.AddSelfReference

2 posts, 0 answers
  1. Simon
    Simon avatar
    1 posts
    Member since:
    Mar 2012

    Posted 17 Mar 2012 Link to this post


    I am currently evaluating the radgridview in UNBOUND mode.

    I have used .Relations.AddSelfReference which works in my scenario very well

    My question is, is it possible to make the indent smaller for the sub rows

    + My Top Row
            My Top Rows Relation #1
            My Top rows Relation #2

    I would like to make this indent smaller

    + My Top Row
        My Top Rows Relation #1
        My Top rows Relation #2

  2. Stefan
    Stefan avatar
    2908 posts

    Posted 21 Mar 2012 Link to this post

    Hello Simon,

    Thank you for writing

    Here is an example demonstrating how you can reduce the indent space - by setting negative Margin of the CellElement:
    void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
               GridDataCellElement dataCell = e.CellElement as GridDataCellElement;
               if (dataCell.ColumnInfo.Name == "Name")
                   GridViewDataRowInfo dataRow = dataCell.RowInfo as GridViewDataRowInfo;
                   if (dataRow != null)
                       if (dataRow.ChildRows.Count == 0)
                           e.CellElement.Margin = new Padding(-20, 0, 0, 0);
                   dataCell.ResetValue(LightVisualElement.MarginProperty, Telerik.WinControls.ValueResetFlags.Local);

    Attached to this post you can find a sample project demonstrating this approach. 

    I hope that you find this information useful.

    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top