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

Hierarchy Child Size

21 Answers 600 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Susan
Top achievements
Rank 1
Susan asked on 19 Feb 2009, 02:26 PM
Does anyone know how to get rid of the box around the children in a hierarchy? There seems to be default size that is set regardless of how many children there are. I have autoresize checked to true. It makes the child records take up more room than they should and the box around the children is annoying.

Susan

21 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 20 Feb 2009, 10:57 AM
Hello Susan,

Thank you for this question.

The border is set through the theme and can be disabled when processing the ViewCellFormatting event. Take a look at this sample code:

void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) 
    if (e.CellElement is GridDetailViewCellElement) 
    { 
        GridDetailViewCellElement cell = e.CellElement as GridDetailViewCellElement; 
        cell.ChildTableElement.DrawBorder = false
        cell.ChildTableElement.TableBodyElement.DrawBorder = false
    } 

You can change the child view height when processing the same event. Use this code:

 
cell.RowInfo.Height = 100; 
 

Do not hesitate to contact us if you have any other questions.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Susan
Top achievements
Rank 1
answered on 10 Mar 2009, 03:56 PM
That actually didn't work. The border around the children group is still there. The children size is fine. There is just a border around the whole children area that we would like to get rid of.
0
Jack
Telerik team
answered on 12 Mar 2009, 01:12 PM
Hi Susan,

This code should work. Could you please open a support ticket and send us your application, so we can test it. I will try to find where is the problem.

I am looking forward to your reply.

Regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Craig Finnigan
Top achievements
Rank 1
answered on 09 Apr 2009, 04:56 PM
I think that I am trying to do something simular to this.  
    I have my RadGridView setup with a childGridViewTemplate.  I want to remove the blank space between the bottom of the ChildGridView and the top of the next parent row.

When i enter the line 

 

If e.CellElement Is GridDetailViewCellElement Then

 

 

End If

I get the error GridDetailViewCellElement  is a type and connot be used as an expression.

Is there something else that I should be doing here in my ViewCellFormatting event?

 

0
gerbrand
Top achievements
Rank 2
answered on 10 Apr 2009, 01:08 PM
Hi Susan,

What I think you have to do:

private void rgvAdserver_ViewCellFormatting(object sender, CellFormattingEventArgs e) 
        { 
            if (!(e.CellElement is GridDetailViewCellElement)) return
            var cell = e.CellElement as GridDetailViewCellElement; 
            if (cell == nullreturn
            cell.ChildTableElement.DrawBorder = false
            cell.ChildTableElement.TableBodyElement.DrawBorder = false
            cell.ChildTableElement.Padding.All = 0; //removes the box around the childs 
        } 

But I'm getting an error on line 8. Saying :
"Cannot modify the return value of 'Telerik.WinControls.RadElement.Padding' because it is not a variable"

But it is a getter, setter. So I'm not sure why I get this error.



0
gerbrand
Top achievements
Rank 2
answered on 10 Apr 2009, 01:41 PM
Okay found a work around for the padding box around the children.

When you make a new theme with the theme builder. You can remove those padding borders easily here.

Once you've saved your theme (.xml), you add a radThemeManager to you form. In this manager you get your just created theme.

Now you need to apply it to your grid. just select the little arrow at the topborder of the gridview. There you can select at "theme name" your created theme.


0
Jack
Telerik team
answered on 10 Apr 2009, 03:24 PM
Hi gerbrand,

Thank you for sharing your solution. Yes, you can use the Visual Style Builder to change easily the visual appearance of our controls.

Regarding the Padding property: It is a value type and you can't change its properties this way. You should create a new Padding, set its properties and then assign the new Padding object. Here is a sample:

cell.ChildTableElement.Padding.All = new Padding(0); 
 

Craig, use the code below to remove the spacing programmatically:

Private Sub radGridView1_ViewCellFormatting(ByVal sender As ObjectByVal e As CellFormattingEventArgs) 
    Dim cell As GridDetailViewCellElement = TryCast(e.CellElement, GridDetailViewCellElement) 
    If cell IsNot Nothing Then 
        e.CellElement.Padding = New Padding(0) 
    End If 
End Sub 
 
 

Should you have further questions, feel free to write us.

Kind regards,
Jack
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Craig Finnigan
Top achievements
Rank 1
answered on 14 Apr 2009, 09:53 PM
Dear Jack "in the box", 
    This code did not work... I put this code in and i still see the space between the bottom of the ChildGridView and the next row of the parent grid view.
Any other suggestions?
0
Julian Benkov
Telerik team
answered on 17 Apr 2009, 01:04 PM
Hello Craig Finnigan,

You can also reset the BorderWidth of the DetailViewCellElement:

Private Sub HierarchyForm_Load(ByVal sender As ObjectByVal e As EventArgs) 
    ' TODO: This line of code loads data into the 'northwindDataSet.Orders' table. You can move, or remove it, as needed. 
    Me.ordersTableAdapter.Fill(Me.northwindDataSet.Orders) 
    ' TODO: This line of code loads data into the 'northwindDataSet.Customers' table. You can move, or remove it, as needed. 
    Me.customersTableAdapter.Fill(Me.northwindDataSet.Customers) 
     
    AddHandler Me.radGridView1.ViewCellFormatting, AddressOf radGridView1_ViewCellFormatting 
End Sub 
 
Private Sub radGridView1_ViewCellFormatting(ByVal sender As ObjectByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) 
    Dim cell As GridDetailViewCellElement = TryCast(e.CellElement, GridDetailViewCellElement) 
    If cell IsNot Nothing Then 
        e.CellElement.Padding = New Padding(0) 
        e.CellElement.BorderWidth = 0 
    End If 
End Sub 

Do not hesitate to write me back if you have further questions.

Sincerely yours,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jeremy Murtishaw
Top achievements
Rank 1
answered on 17 May 2009, 03:14 AM
Hello,

I'm actually still having trouble with this, despite the info on this thread and my research around the site. I would like to programmatically get rid of the padding and border around the embedded hierarchical child grids. I've tried all of the code listed in this section and none of it is working for me.

Also, a related issue I'm having is with the Plus signs for expanding rows. I've seen many ASP.NET postings where its explained how to get rid of this image if there are no children for a particular row, but I haven't seen the equivalent for C#. Can anyone help me here?

Thanks!
Jeremy
0
Nikolay
Telerik team
answered on 20 May 2009, 10:51 AM
Hi Jeremy Murtishaw,

I would like to receive more information about the issues that you have with the Padding of the child views. The code that my colleague Julian suggested removes the padding, so I cannot understand what is the exact look that you want to achieve. Please open a new support ticket and send me screenshots with the problem areas highlighted and details about the desired look.

As to your second question, I suppose the you mean WinForms technology with a code snippet in C#. If so, please refer to the following Knowledge Base article: Hide expand/collapse image in hierarchical RadGridView.

If you have additional questions, feel free to contact me.

All the best,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
olivier pareige
Top achievements
Rank 1
answered on 18 May 2010, 03:13 PM
Hello,

This is the same for me : I would like to programmatically get rid of the padding and border around the embedded hierarchical child grids. I've tried all the solutions proposed in this thread, I've tried a lot of other things, but I Didn't manage to do that.

Is there news about this issue ?

Thanks in advance !
0
Jack
Telerik team
answered on 20 May 2010, 05:19 PM
Hi olivier,

The solution provided in this forum should do the job. Basically you should set the Padding to 0 and disable the border by setting DrawBorder property to false

If the issue continues to appear, please specify which is your version of RadControls for WinForms and send us your application in a support ticket and we will try to locate the issue.

Regards,

Jack
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
olivier pareige
Top achievements
Rank 1
answered on 25 May 2010, 09:03 AM
Hello,

Thanks for your response. For me it does'nt work. Perhaps am i doing something wrong. I've done a little solution as example. I'll open a support ticket and send you the solution.

Thanks.


0
Jack
Telerik team
answered on 27 May 2010, 04:23 PM
Hi olivier pareige,

Thank you for getting back to us. We are looking forward to receiving your project.

All the best,
Jack
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
David
Top achievements
Rank 1
answered on 27 Sep 2010, 09:37 PM
I too would like to know how this was resolved.  It looks to me that the responses from Telerik were trying to show how to set the border style and width for a cell within the child grid, but the question was specifically regarding the border around the entire child grid itself.  

I'm spending an inordinate amount of time trying to get this simple styling issue to work, but I'd love to see some working code for the last issue. 
0
Nikolay
Telerik team
answered on 29 Sep 2010, 12:03 PM
Hi David,

In order to hide the border of RadGridView, please refer to the code snippet below:
this.radGridView1.GridViewElement.BorderWidth = 0;
this.radGridView1.Padding = new Padding(0);

I hope this helps.

Sincerely yours,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Aarvey
Top achievements
Rank 1
answered on 25 Mar 2013, 04:22 PM
I have the same problem in WPF RadGridView. How can i solve the padding issue with the hierarchical child.
0
Stefan
Telerik team
answered on 26 Mar 2013, 06:33 AM
Hello Aarvey,

This forum concerns RadControls for WinForms, while your question is related to RadControls for WPF. Please address your question in the appropriate forums, so you can get adequate assistance: http://www.telerik.com/community/forums/wpf/gridview.aspx.
 
All the best,
Stefan
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
John
Top achievements
Rank 1
answered on 14 May 2019, 04:42 PM

This solution worked for me.  Perhaps the reason this code is not working for some others is it is missing the Handles clause in the Sub decalaration:

    Private Sub radGridView1_ViewCellFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles radGridView1.ViewCellFormatting

 

--John

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 May 2019, 06:56 AM
Hello, John,     

I am glad that the provided solution in this forum thread was useful for your case. Note that the provided code snippet in the reply from 17-Apr-2009 has a subscription to the ViewCellFormatting event. Hence, the "Handles" part in VB.NET is necessary only in case you don't have a subscription explicitly.

If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Susan
Top achievements
Rank 1
Answers by
Jack
Telerik team
Susan
Top achievements
Rank 1
Craig Finnigan
Top achievements
Rank 1
gerbrand
Top achievements
Rank 2
Julian Benkov
Telerik team
Jeremy Murtishaw
Top achievements
Rank 1
Nikolay
Telerik team
olivier pareige
Top achievements
Rank 1
David
Top achievements
Rank 1
Aarvey
Top achievements
Rank 1
Stefan
Telerik team
John
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or