Hello
I got some questions to Load and Save WinGrid layouts, the behavior on getting over 50thousand lines of designer code when adding a bindingsource. The bindingsource look on a datasource table which has an 'inherited' parent/children relation on itself.
My first problem is the datatable in my datasource which has a recursiv character / parent/child relation. The designer file sometimes takes few minutes to load and has over 50.000 lines of code an nearly a thousand band inherited. I tried the property singleband and maxbanddepth to 1. But i am not shure if this was going to help or the fact that i deleted the table relation on itself in the dataset.
My second problem is about loading the display layout. I wanted to load the layout from a database depending which user is 'logged in'. For this behavior i got a usercontrol with a wingrid. The first 'standard' design comes from a lyt-file when no layout (or standard-layout) could be found in the database. But sometimes columns which i made hidden are visible again and i don't know why.
Third problem is that after some changes the event 'AfterRowLayoutItemResized' didn't fire when i changed the size of a column-width or row-height. I wondered why know cause earlier it fires at this point. I tryed to delete the event and add it again but it still didn't work
And now a forth problem is that i could save the layout, but the layout won't load correctly. The column-width changes load correctly. But the Row-height changes won't load.
Thanks for your support.
Greetings from germany
Dietrich
Sample Code:
UserControl
private string user = GridExtensionClass.STANDARD_USER; public string User // this i how the usercontrol gets the userchange from the parent frame { get { return user; } set { user = value; GridExtensionClass.loadLayout(ultraGridWorkgroups, ecU_UserLayoutsTableAdapter1, user); ultraGridWorkgroups.Refresh(); } }
private void ultraGridWorkgroups_AfterRowResize(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e) { GridExtensionClass.saveLayout(ultraGridWorkgroups, ecU_UserLayoutsTableAdapter1, user); } private void ultraGridWorkgroups_AfterColPosChanged(object sender, Infragistics.Win.UltraWinGrid.AfterColPosChangedEventArgs e) { GridExtensionClass.saveLayout(ultraGridWorkgroups, ecU_UserLayoutsTableAdapter1, user); } private void ultraGridWorkgroups_AfterRowLayoutItemResized(object sender, Infragistics.Win.UltraWinGrid.AfterRowLayoutItemResizedEventArgs e) //doesn't work anymore, event won't fire on row size/header changes { GridExtensionClass.saveLayout(ultraGridWorkgroups, ecU_UserLayoutsTableAdapter1, user); }
HelperFile:
public static void loadLayout(UltraGrid grid, ECU_UserLayoutsTableAdapter tableAdapter, string actualUser) { byte[] myData = (byte[])tableAdapter.ecu_loadLayout(actualUser, grid.Name); try { //grid.ResetLayouts(); //no changes on the row heights issue //grid.ResetDisplayLayout(); //no changes on the row heights issue grid.DisplayLayout.Load(new MemoryStream(myData)); } catch (ArgumentNullException ane) //if no layout is found in the database { loadRessourcesLayout(grid,tableAdapter); //GridExtensionClass.saveLayout(grid, tableAdapter, "Standard"); } }
I have come a little further but i got still the problem, that the 'AfterRowLayoutItemResized' Event doesn't fire anymore.
Code:
public UltraGridLocationGroups() { InitializeComponent(); GridExtensionClass.loadAppearance(ultraGridLocationGroupsTable, ecU_UserLayoutsTableAdapter1, user); }
public string User { get { return user; } set { user = value; GridExtensionClass.loadAppearance(ultraGridLocationGroupsTable, ecU_UserLayoutsTableAdapter1, user); } }
//event still doesn't fire
private void ultraGridLocationsTable_AfterRowLayoutItemResized(object sender, Infragistics.Win.UltraWinGrid.AfterRowLayoutItemResizedEventArgs e) { GridExtensionClass.saveAppearance(ultraGridLocationGroupsTable, ecU_UserLayoutsTableAdapter1, user); }
Code (HelperClass):
public static void loadAppearance(UltraGrid grid, ECU_UserLayoutsTableAdapter tableAdapter, string actualUser) { byte[] myData = (byte[])tableAdapter.ecu_loadLayout(actualUser, grid.Name); try { grid.DisplayLayout.Load(new MemoryStream(myData),PropertyCategories.Bands); } catch (ArgumentNullException ane) { loadRessourcesLayout(grid,tableAdapter); } } private static void loadRessourcesLayout (UltraGrid grid,ECU_UserLayoutsTableAdapter tableAdpter) { switch (grid.Name) { case "ultraGridAllWorkpiecesTable": grid.DisplayLayout.Load(new MemoryStream(global::Steuergeraetemanager.Resources.Properties.Resources.AllWorkpiecesLayout)); saveStandardAppearance(grid, tableAdpter); break; case "ultraGridLocationsTable": grid.DisplayLayout.Load(new MemoryStream(global::Steuergeraetemanager.Resources.Properties.Resources.LocationsLayout)); saveStandardAppearance(grid, tableAdpter); break; case "ultraGridLocationGroupsTable": grid.DisplayLayout.Load(new MemoryStream(global::Steuergeraetemanager.Resources.Properties.Resources.LocationGroupsLayout)); saveStandardAppearance(grid, tableAdpter); break; default: MessageBox.Show("Layout not found! Following TableLayout could not be found:\\n" + grid.Name); break; } }
public static void saveAppearance(UltraGrid grid, ECU_UserLayoutsTableAdapter tableAdapter,string actualUser) { if (!actualUser.Equals(GridExtensionClass.STANDARD_USER)) { byte[] myData = new byte[0]; MemoryStream myStream = new MemoryStream(); grid.DisplayLayout.Save(myStream,PropertyCategories.Bands); myData = myStream.ToArray(); tableAdapter.ecu_saveLayout(actualUser, grid.Name, myData); } else { if (tableAdapter.ecu_loadLayout(actualUser, grid.Name) == null) { loadRessourcesLayout(grid, tableAdapter); byte[] myData = new byte[0]; MemoryStream myStream = new MemoryStream(); grid.DisplayLayout.Save(myStream,PropertyCategories.All); myData = myStream.ToArray(); tableAdapter.ecu_saveLayout(actualUser, grid.Name, myData); } } }
So far so good.
I changed the the rowlayoutstyle of the band to columnlayout.
But i got still the following problem.
When i run the usercontrol and do change the property 'Name' of the control the layout of the grid changes the way it should. A saved layout of a user will be displayed, if no layout for the user is saved the standard layout will be loaded.
Now the problem: after i saved the layout for a user, the loading as described above doesn't work anymore. What am i missing? I can't see why the layout isn't loaded the correct way anymore.
When i restarted the user control all works fine till i save a user layout.
I can't see why.
I hope someone can help me on this issue.
Thx