I recognized a strange behaviour from the UltraGrid, based on the type of the grids parent control.
If the parent control is a System.Windows.Forms.UserControl, the GridObjects (like bands, columns, rows etc.) are created earlier than, when the parent control is a System.Windows.Forms.Panel.
Is there any explanation for this behavior? We changed the type of the parent control and we got many exceptions, because we accessed those GridObjects at a time when the grid is not builded completely.
I cannot attach a sample, because its deep in our application engine. And i cannot attach the whole application with source code, because of obvious reasons.
Regards
Hello,
If you are using the designer to set up the WinGrid, then when you are using the WinGrid or any other control the settings that you set at design time will be in InitializeComponent of the UserControl and this would be called from the constructor of that UserControl. When a Panel is used, the settings will be in InitializeComponent of the Form.
Since the constructor needs to be called before objects are accessed, it makes sence that when the WinGrid is used on a UserControl will have the logic from the designer executed earlier.
If what I have described above doesn't match what you are doing, please provide me more details.
Alan
In general, it's a good idea to verify the existance of data-related objects like columns before you try to access them.
For example, if you are using the InitializeLayout or InitializeRow events of the grid, you should use the Exists method on the Columns collection to make sure a column has been created before you attempt to access that column.