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

Child Grid Width

1 Answer 40 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 28 Jun 2011, 04:34 PM
Hello,

I'm trying to set the grid width of the child table but cannot find the property/method to do so?
I've set the outer grid width fine I think.
Dim OrderLinesTemplate As New GridViewTemplate
       OrderLinesTemplate.AllowAddNewRow = False
       OrderLinesTemplate.DataSource = myOrderLines
       OrderLinesTemplate.Columns(0).Width = 100
       OrderLinesTemplate.Columns(1).Width = 200
       OrderLinesTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None
       Me.RadGridView1.MasterTemplate.Templates.Add(OrderLinesTemplate)

and then try to set the inner (child) grid on the on gridview formatting event:-
Private Sub RadGridView1_ViewCellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.ViewCellFormatting
 
        If TypeOf e.CellElement Is GridDetailViewCellElement Then
            e.CellElement.BorderWidth = 10
            e.CellElement.AutoSize = False
            e.CellElement.Size = New System.Drawing.Size(350, 150)
        End If
    End Sub

Attached is the screen print of the output and what I'm trying to achieve for clarity.

Many thanks

Terry




1 Answer, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 01 Jul 2011, 02:20 PM
Hello Terry,

Thank you for writing.

Actually, you are on the right track. However, you should set the size properties to the child table element of the cell, but not to the cell itself. Please consider the following code:
Private Sub radGridView1_ViewCellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs)
    If TypeOf e.CellElement Is GridDetailViewCellElement Then
        e.CellElement.Children(0).StretchHorizontally = False
        e.CellElement.Children(0).AutoSize = False
        e.CellElement.Children(0).Size = New Size(350, 150)
        e.CellElement.BorderWidth = 10
    End If
End Sub

Hope this helps. Let me know if you have any other questions.

Greetings,
Martin Vasilev
the Telerik team
Registration for Q2 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting July 18th and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
GridView
Asked by
Terry
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Share this question
or