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
I am going to require more information regarding your application.
1. What seems to trigger this issue? 2. Can this issue be reproduced? How? Please provide steps. 3. What does your application consist of besides an UltraWinGrid? Provide screenshots compressed.
In order to properly assist you I require an isolated sample that demonstrates the issue. From there I can take a look at your application and try and reproduce the behavior on my end.
This scenario is to hard to create a example.
I bind the grid to a dataset in the designer and at runtime all my configurations to the grid are wiped out. The grid is acting like it was bound to a completely different datasource when it was not. I know this because there is NO code on this form other than the auto generated designer code.
Basically i want to know how the datasource determines to now used the configured designer code and cause a complete rebind.
I attached a sample that demonstrates that you can change the datasource and keep the appearance the same from the designer. I have established a bind as well. In code I set a new datasource for the grid before it's opened. You can open Form1 and see the way it looks with a bind pre-established.
I would like for you to modify this sample to see if you can reproduce the behavior for me. Let me know if the sample is suitable to work with and perhaps we can use it to exchange ideas.
I will see if i can get it to be reproduced.
in the meantime can you tell me how the grid tracks that a datasource has changed?
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.