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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DataBoundGrid Columns Not Available

Thread ID:





8574 Nov 12,2003 03:37 PM UTC Nov 14,2003 12:02 AM UTC WinForms 6
Tags: GridControl
Jeff Block
Asked On November 12, 2003 03:37 PM UTC

I am binding to a DataTable in the following manner: orderSelection.SelectionGrid.DataSource = dataset.Orders; Debug.WriteLine( string.Format( "There are {0} columns in dataset.Orders.Columns collection.", dataset.Orders.Columns.Count )); GridModelDataBinder binder = orderSelection.SelectionGrid.Binder; Debug.WriteLine( string.Format( "There are {0} columns in binder.InternalColumns collection.", binder.InternalColumns.Count )); foreach ( GridBoundColumn gbc in binder.InternalColumns ) { Debug.WriteLine( string.Format( @"\tColumnName: {0}", gbc.MappingName )); } Where orderSelection.SelectionGrid is a GridDataBoundGrid on a dynamically created user control. The debug statements display the following: There are 40 columns in dataset.Orders.Columns collection. There are 0 columns in binder.InternalColumns collection. What do I need to do is set some column properties (hide some, alignment, etc.) for the grid, but there are no columns found to change. Any help greatly appreciated! Thanks...

Administrator [Syncfusion]
Replied On November 12, 2003 05:43 PM UTC

Has orderSelection.SelectionGrid been added to the userControl's Controls collection before you set the orderSelection.SelectionGrid.DataSource property? If this does not make things work, can you post the code as to how you create the user control and create the grid, and parent the grid to the user control?

Jeff Block
Replied On November 13, 2003 01:10 PM UTC

Thanks for the quick response Clay, I headed in another direction after posting and just revisited this morning. That said, I will review creation as you suggested, but I'm almost 100% sure it is created. However, without even doing that, if the grid wasn't created, I would expect the attempt to retrieve the binder would fail with a null reference exception. I'll get back with more details as requested... Jeff

Jeff Block
Replied On November 13, 2003 10:04 PM UTC

Basically, my form initializes the ctlOrderSelection, which in turn instantiates the ctlEntitySelection in it's constructor. The SelectionGrid is a design-time placed control of the ctlEntitySelection. ctlOrderSelection is instantiated with this code from the form: orderSelection = new ctlOrderSelection( dataset ); orderSelection.Parent = this.workingPanel; orderSelection.Dock = DockStyle.Fill; orderSelection.Visible = true; It shows up just fine, but _all_ columns are displayed (40!) and works okay (still got some kinks to work out), but just can't seem to control the columns like I think I should. Any thoughts and/or questions welcome... Jeff

Administrator [Syncfusion]
Replied On November 13, 2003 11:42 PM UTC

I amy be overlooking something, but I don't see anywhere in your code that you add SelectionGrid to its parent's Controls collecting. Ie, no code like: this.Controls.Add(SelectionGrid); anywhere in the code you sent.

Jeff Block
Replied On November 13, 2003 11:54 PM UTC

Hmmm, do I actually have to do that manually? Guess I was under the impression that adding it to the control through the designer would actually add it to the Controls collection. I'll try it! Thanks for the eyes... Jeff

Jeff Block
Replied On November 14, 2003 12:02 AM UTC

Wow...that worked like a charm! At least the InternalColumns exist are are enumerated correctly. Still confused on exactly what that is doing, or more accurately, why it is necessary. Guess I'm in for some more investigation. Now the real work begins. I'm sure I'll have more questions... ;>) Your tireless efforts are greatly appreciated. Thanks. Jeff


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

Live Chat Icon For mobile
Live Chat Icon