This is a migrated thread and some comments may be shown as answers.

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

1 Answer 110 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 17 Mar 2012, 01:27 PM
Hi,

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

Thanks

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 21 Mar 2012, 02:19 PM
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);
                   }
               }
           }
           else
           {
               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.

Greetings,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Simon
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or