We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Sorry Another Question

Thread ID:





24070 Jan 27,2005 02:53 PM UTC Jan 27,2005 03:31 PM UTC WinForms 1
Tags: GridControl
Adrian Lin
Asked On January 27, 2005 02:53 PM UTC

I stored a datatable in an arraylist. I take that arraylist and pass the stored datatable to a new instance of a datatable and then set a databounddatagrid''s data source to that datatable. If i pass it to a databound grid that I created through the designer I can see it fine and i can access the items within it. However if I pass it to a databound grid i created in the code then i cant access the items within it i get blank values. Also which I find very pelicuar I created both grids and I passed the datatable to the programmed databound grid and then set the designer databound grid to the datasource of the programmed databound grid and I can get fine results biut I still cant get values for the programmed datagrid what gives? Here is the code: Private Sub ITS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ITS.Click Dim gdbc_DataBoundGrid As New Syncfusion.Windows.Forms.Grid.GridDataBoundGrid Dim dt_DataTable As New DataTable("CC") dt_DataTable = al_StudbookID.Item(0) ''programmed databound grid gdbc_DataBoundGrid.DataSource = dt_DataTable ''databound grid in the designer GridDataBoundGrid1.DataSource = gdbc_DataBoundGrid.DataSource ''this msgbox gives me a blank value MsgBox(gdbc_DataBoundGrid.Item(1, 1).Text()) ''this msgbox gives me a proper value MsgBox(GridDataBoundGrid1.Item(1, 1).Text) End Sub

Administrator [Syncfusion]
Replied On January 27, 2005 03:31 PM UTC

A control does not have its BindingContext member set until it is parented which usually happens when you add the control to its parent''s COntrols.Collection. In your code, there is no Me.Controls.Add(gdbc_DataBoundGrid) so the grid does not have a parent and hence gdbc_DataBoundGrid.BindingContext is Nothing. So, one thing you can try is to explicitly create the grid''s BindingContext before you try to use the grid in a bound manner. gdbc_DataBoundGrid.BindingContext = new BindingContext() (Note that Control.BindingContext is marked as an ''advanced'' property in teh VB''s editor, so you will not see it in intellisense unless you have explicitly enabled this in your VisStu properties.) If that does not work, then you can add the grid to the forms'' Controls collection and I suspect that will make things go through OK. gdbc_DataBoundGrid.Visible = True Me.Controls.Add(gdbc_DataBoundGrid)


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon