(c#) Janus GridEX

etienne_marais

Honorary Master
Joined
Mar 16, 2008
Messages
15,093
Anybody well versed with Janus controls ?

I am setting the datasource of a GridEX control and inspection shows that grdAssets.DataSource has a count of 109 after being assigned to assetVerifications.

But when I call grdAssets.GetRows() or grdAssets.GetDataRows(), zero rows are returned.

After setting the datasource the grid is successfully populated on the screen in runtime.

Code:
            grdAssets.DataSource = assetVerifications;

            foreach (Janus.Windows.GridEX.GridEXRow row in grdAssets.GetDataRows())
            {
                row.BeginEdit();
                row.Cells[5].Value = calVerificationDate.Value;
                row.EndEdit();
            }
 
Last edited:

etienne_marais

Honorary Master
Joined
Mar 16, 2008
Messages
15,093
Problem solved. I originally placed the code in the constructor (albeit AFTER InitializeComponent) and it seems all components are not guaranteed to be set up properly at that stage. Moving the code to the form's Load event solved it. Had similar problems before, so mad at myself for not realizing it sooner.

Does anybody have insights for me though as to why the constructor is a bad place to write UI code ? I would have thought InitializeComponent() get's things all set up for you...
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
6,282
Problem solved. I originally placed the code in the constructor (albeit AFTER InitializeComponent) and it seems all components are not guaranteed to be set up properly at that stage. Moving the code to the form's Load event solved it. Had similar problems before, so mad at myself for not realizing it sooner.

Does anybody have insights for me though as to why the constructor is a bad place to write UI code ? I would have thought InitializeComponent() get's things all set up for you...
It's a common practice but not a concrete rule -- best to check API docs for clarity.
Re practice: Init events are usually for setup of the component internals, whereas load events are usually for data / state inits.
 

etienne_marais

Honorary Master
Joined
Mar 16, 2008
Messages
15,093
[)roi(];18228499 said:
It's a common practice but not a concrete rule -- best to check API docs for clarity.
Re practice: Init events are usually for setup of the component internals, whereas load events are usually for data / state inits.

Thanks Droid
 
Top