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.
Unfortunately, activation email could not send to your email. Please try again.

DataBoundGrid Columns Not Available

Thread ID:

Created:

Updated:

Platform:

Replies:

8574 Nov 12,2003 10:37 AM Nov 13,2003 07:02 PM Windows Forms 6
loading
Tags: GridControl
Jeff Block
Asked On November 12, 2003 10:37 AM

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 12:43 PM

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 08:10 AM

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 05:04 PM

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 06:42 PM

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 06:54 PM

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 13, 2003 07:02 PM

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

CONFIRMATION

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.

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.

;