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

RadGridView in DockPanel

4 Answers 232 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Filipe Rodrigues
Top achievements
Rank 1
Filipe Rodrigues asked on 18 May 2007, 04:25 PM
I'm creating a RadGridview inside a DockPanel in Runtime but the panel shows empty.

Here is my code:

Dim dp As New DockPanel
dp.Text = "Some Text"
dp.CloseButtonVisible = False
Dim dg As New RadGridView
Dim ds As New DataSet
ds.Tables.Add("Table")
ds.Tables(0).Columns.Add("Client")
ds.Tables(0).Columns.Add("Qt")
ds.Tables(0).Rows.Add(New String() {"Client 1", "200"})
ds.Tables(0).Rows.Add(New String() {"Client 2", "500"})
ds.Tables(0).Rows.Add(New String() {"Client 4", "370"})
ds.Tables(0).Rows.Add(New String() {"Client 3", "943"})
dg.DataSource = ds.Tables(0).DefaultView
dg.Dock = DockStyle.Fill
dg.datab()
dp.Controls.Add(dg)
DockingManager1.PrimarySite.SetDock(dp, DockPosition.Fill)

Is this code correct?

4 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 21 May 2007, 12:46 PM
Hello Filipe,

Your code is correct and we not find any problem with it. In order to help you out we will need a simple example to reproduce it locally. Please, open a support ticket and attach the files.

Thank you for the feedback.

 
Greetings,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Filipe Rodrigues
Top achievements
Rank 1
answered on 21 May 2007, 01:35 PM
The panel have something inside (a radgridview) but the grid shows without any rows...I opened a support ticket and attached a file with my test application.
Thanks.
0
Julian Benkov
Telerik team
answered on 21 May 2007, 03:06 PM
Hi Filipe,

Thank you for the project.

All you need to do is reorder some of your code to solve the problem:

Private Sub RadButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton1.Click 
        Dim dp As New DockPanel 
        dp.Text = "Some Text" 
        dp.CloseButtonVisible = False 
        Dim dg As New RadGridView 
        Dim ds As New DataSet 
        ds.Tables.Add("Table") 
        ds.Tables(0).Columns.Add("Client") 
        ds.Tables(0).Columns.Add("Qt") 
        ds.Tables(0).Rows.Add(New String() {"Client 1", "200"}) 
        dz.Tables(0).Rows.Add(New String() {"Client 2", "500"}) 
        dz.Tables(0).Rows.Add(New String() {"Client 4", "370"}) 
        dz.Tables(0).Rows.Add(New String() {"Client 3", "943"}) 
        dg.Dock = DockStyle.Fill 
        dp.Controls.Add(dg) 
        DockingManager1.PrimarySite.SetDock(dp, DockPosition.Fill) 
        dg.DataSource = dz.Tables(0).DefaultView 
    End Sub 

The is as follows: when binding RadGridView it searches for BindingContext but BindingContext is valid after the grid is added to the controls' collections of the Form object. When you add RadGridView to the DockPanel and call SetDock then you will have a valid BindingContext.
 

Regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Filipe Rodrigues
Top achievements
Rank 1
answered on 21 May 2007, 03:10 PM
Hi, thanks for the quick reply.

I binded dataset to the radgridview after docking the panel and it worked!
Thanks!
Tags
GridView
Asked by
Filipe Rodrigues
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Filipe Rodrigues
Top achievements
Rank 1
Share this question
or