Hello,
I am trying to find out why column settings are not persisting. I have a Dataset with a single table which has 40+ columns.
The form has a single grid on it which has its datasource set in designer mode. Most columns have editor controls, heading captions changed, etc. The designer opens correctly in visual studio.
During runtime (no code is running other than initializecompent (designer stuff), the form opens and the grid looks as if i just changed that datasource, all columns are visible and no settings which are visible in the designer are shown.
How does the ultragrid know that the datasource that is set in the initializecomponent is different, why would it act as if its different? Does it store some metadata somewhere?
Thank you,B
Hi Brandon,
I can only guess, but my theory is that the grid was getting added to the form (or it's parent control) after the DataSource was already set. So what that means is that the grid had no parent control at the time the DataSoure property was set. Since there is no parent control, there is no BindingContext and the grid would be unable to get the data. Then... when you add the grid to it's parent, it suddenly gets a BindingContext. The grid watches for when the BindingContext changes are re-binds. But since the grid was already bound once with no data, the layout was already lost.
Hello Brandon,
May I ask if you solved the answer to your question? Let us know if you have any additional questions. Thanks in advance.
Mike,
I figured out the problem, but can't tell you why it was happening. In the designer the grid itself wasn't being added to the form traditionally. EX, me.Controls.add(grid)
Instead we had another control that was on the form and the grid was assigned to that control. For whatever reason this caused the layouts to reset. I added the grid using me.controls and during load I assign the grid to our control and everythign worked.
Any ideas why that would reset the layout? You can check out the designer in a previous post.
Thank you,
Brandon
Hi,
Well, at least you have a workaround for now.
If you want to continue to try to track down why this is happening, then you could try hooking into the data source notifications and see if you are getting a Reset notification form the Data Source. But it will be tricky because the problem has already occurred when Form_Load fires. So that means you need to use the form's constructor to hook the notifications. And getting the same data object the grid is using is not trivial. It would be a lot easier if you could reproduce the issue in a sample project and post it here so I could debug it. But I understand that might not be possible, since I probably can't access your data source.
The form's constructor by default handles all the designer properties, data-binds, and event hooks. Therefore, if you have any logic in the Form Load event at runtime; this won't execute until the designer code, constructor logic has been completed. It depends on when you bind your grid too. In other words the initialize layout event will execute every time you bind your grid before the form load event executes. (Ex. Bind your data in the designer or in the constructor)
Have you solved your issue? Let me know if you have any additional questions.