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.
Syncfusion Feedback

Loading DataBoundGrid style from a save configuration

Thread ID:

Created:

Updated:

Platform:

Replies:

7405 Sep 24,2003 12:44 PM UTC Sep 25,2003 11:31 AM UTC Windows Forms 3
loading
Tags: GridControl
Doug Lind
Asked On September 24, 2003 12:44 PM UTC

Hi, I'm trying to reload style options for a DataBoundGrid, from a previously saved parameter list. Reading and writing the parameters is no problem. What is giving me fits though is determining when the grid has completed initialization, so I can update the settings. This is done as part of a grid restore operation, when the app is started. Currently I'm trying to do it from an Init() sub, that is run after InitializeComponent() (the Windows Form Designer generated code) has completed. When I go to update the DataBoundColumns, both g.GridBoundColumns.count and g.Binder.InternalColumns.count, are set to 0. This of course generates errors if I try to update the columns. Subsequent checks (after the load) shows columns in g.Binder.InternalColumns. Can you tell me when DataBoundGrid initialization has completed and what event(s) I can use as an indication it is safe to update? FYI, the DataBoundGrid is contained in your DockingManager component. Thanks, Doug

Administrator [Syncfusion]
Replied On September 24, 2003 05:53 PM UTC

There is no such init event because the grid itsself only can reacts to actions that happen in your parent forms code. The reason that the InternalColumns collection is empty at that point is that probably the binding context has not been specified. The BindingContext of a control is only available once all controls have been properly parented to their respective parent controls. So, if you have the grid inside a panel and that panel will later be added to a form. The grids binding context is set when the panel is added to the form. At that time the grids gets a BindingContextChanged notification and will call InitializeColumns if they have not yet been initialized. If on the other side the grid is already added to a form and therefore the binding context initialized then the grid will initialize columns as soon as you initialize its DataSource property. Hope this is not explained too complicate. So, some events you might look for are BindingContextChanged and DataSourceChanged. Best is of course if the parent form could fire a quick method call to your grid once it is done loading, e.g. from Form_Load. Stefan

Doug Lind
Replied On September 25, 2003 11:24 AM UTC

Thanks for the explanation. I'll give the form load event a try. I avoided that initially because the description indicated that it was called "when" the the form was loaded and it seemed that what was need was "after". The other two events you mentioned may also be a good bet. If nothing else I figured I could set up a timer upon loading the form to watch for grid initialization to complete, then dispose of the timer and perform the update. Kinda klunky but it should work. Again, thanks Doug > > There is no such init event because the grid itsself only can reacts to actions that happen in your parent forms code. > > The reason that the InternalColumns collection is empty at that point is that probably the binding context has not been specified. The BindingContext of a control is only available once all controls have been properly parented to their respective parent controls. > > So, if you have the grid inside a panel and that panel will later be added to a form. The grids binding context is set when the panel is added to the form. At that time the grids gets a BindingContextChanged notification and will call InitializeColumns if they have not yet been initialized. > > If on the other side the grid is already added to a form and therefore the binding context initialized then the grid will initialize columns as soon as you initialize its DataSource property. > > Hope this is not explained too complicate. > > So, some events you might look for are BindingContextChanged and DataSourceChanged. > > Best is of course if the parent form could fire a quick method call to your grid once it is done loading, e.g. from Form_Load. > > Stefan >

Doug Lind
Replied On September 25, 2003 11:31 AM UTC

Stefan, FYI: The form load event did the job.

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.

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

;