Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Inherited winGrid, NewBandLoadStyle, NewColumnLoadStyle, when to implement
posted

I'm inheriting a winGrid, binding to BindingSource, using LinqToSQL and EntityFramework. Works GREAT, a boon to production.

In design, I setup my display of bands/columns either the the designer or thru InitializeLayout and all is fine.

If I later update my linq dbml file with new properties (columns in grid) and/or associations (bands in grid), I DON'T want those new columns/tables to change the structure of my grid automatically. So I've set the NewBandLoadStyle and NewColumnLoadStyle to HIDE in my INHERITED control's NEW constructor.

But I really don't want it on NEW, because I'd like to see all of the columns/bands in the designer when I design the grid. And if later, after I've already done my design work on the grid, I alter the dbml file, I don't want those changes to add it's new columns/bands to the grid.

The question is...  on what grid event should I set NewBandLoadStyle and NewColumnLoadStye to HIDE? I only want this these two properties to kick in on subsequent design of the grid (after a dbml object was altered), wherein I would manually show the new columns/bands as appropriate.

Parents
  • 469350
    Suggested Answer
    Offline posted

    Hi,

    I don't think this is possible. If you change the grid's structure at design-time, then the run-time layout will be changed. So setting NewColumnLoadStyle at some later point would be too late - the columns would already be int he grid and are therefore no longer "new".

    What I recommend is that you save the grid's Layout into a file or into the Layouts collection of the grid. You can do this at design-time, using the layout wizard (it's on the menu when you right click on the grid in the designer). Then you can load that layout into he grid at run-time. This way, when you add a column or alter your data structure, the grid will still display correctly at run-time (assuming that the structure matches up enough to load the layout at all).

    The other option would be to simply do everything in the InitializeLayout event and that way it will only affect the run-time display of the grid. Personally, this is the way I would do it. It's a bit more work up front, but I think it will save you from some of the quirkiness of the form designer in the long run.

Reply Children
No Data