I need a simplest way to save the toolbars positions on a form.
I have an UltraToolbarsManager, but only SaveAsXml/Binary with saveCustomizations = False works. I tested, but apparently this does not remember the toolbars positions when i reopen the form.
If I set saveCustomizations = True, then a System.ApplicationException was unhandled exceptions appears, indicating some serialization problems, that appears:
System.ApplicationException was unhandled Message=Error encountered while serializing data into stream. Source=Infragistics2.Win.UltraWinToolbars.v6.3 StackTrace: at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.SaveHelper(Stream stream, Boolean saveAsBinary, Boolean saveCustomizations) at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.SaveAsXml(String filename, Boolean saveCustomizations) at MyNamespace.MyForms.MyForm.SavePreference() at MyNamespace.MyForms.MyForm.MyForm_FormClosed(Object sender, FormClosedEventArgs e)
The same story is with BinarySerialization, or with UltraToolbarsManager.SaveSettings = Tru, or also SaveComponentSetting()...
What to do? How can I recuperate the toolbars coordinates to save them into the DB or file manually?
Hello Serhiol,
The easiest way to achieve desired behavior could be if you are using both methods:
ultraToolbarsManager1.SaveComponentSettings();
ultraToolbarsManager1.LoadComponentSettings();
I made a test using our latest available versions and everything works properly. Could you please tell me what is your current version and do you have any installed service release and which one.
Let me know if you have any questions.
Regards
Hi, Georgi, thank you wor your reply.
As I described in my post I already used the SaveComponentSettings() but failed. with the specified error.
Also from the error message above we can see the Infragistics version 6.3... I suppose in the classical variant of a toolbar the serialization works, but if I have some images (handlers) or other kind of "non-standard" toolbars options, the serialization fails.
What will be great that even some elements (like some images buttons or stuff) can't be serialized, at least other elements be serialized, but not if one element fails to be serialized, all others fails too... is not very good.
Thanks for provided information. Please note that I made my tests with very complicate UltraToolbarManager with many different tools, styles and so on. I think that the mentioned issue exist in your version 6.3. Please note that the product lifecycle of this version is expired. More details you could find at http://ko.infragistics.com/help/product-lifecycle/ My suggestion is to use current supported versions 12.1 or 12.2.
Let me know if you have any further questions.
OK, I understand. We will think to switch to the latest version, but actually this request perhaps some money and specially time to reintroduce the new controls into the old code that I suppose should not be 100% compatible between 6 and 12 versions.
As for now, is there a known way to reposition the toolbars in a specified order?
Have a look on this:
Private Sub SaveToolbarSettings()
Dim toolbars As New SerializableDictionary(Of String, ToolbarUserSettings)
Dim theManager As UltraToolbarsManager = Me._ToolbarsManager
For Each tbar As UltraToolbar In theManager.Toolbars
Dim settings As New ToolbarUserSettings
settings.IsMainMenuBar = tbar.IsMainMenuBar
settings.IsStockToolbar = tbar.IsStockToolbar
settings.ShowInToolbarList = tbar.ShowInToolbarList
settings.Visible = tbar.Visible
settings.DockedPosition = tbar.DockedPosition
settings.DockedRow = tbar.DockedRow
settings.DockedColumn = tbar.DockedColumn
settings.FloatingLocation = tbar.FloatingLocation
settings.FloatingSize = tbar.FloatingSize
toolbars.Add(tbar.Key, settings)
Next tbar
toolbars.SerializeToFile("myToolbarSettingsFile.xml")
End Sub
I save and restore the toolbars positions in the same order.
This works good, but only for floatting toolbars, the others are re-arranged in strange way, the dimensions and tools behaves strange...
Is there a specific order in that I should restore the toolbar's positions, or other settings that I missed?
I just need to restore the position of the toolbars on the form, any other settings are not required.
This is how I restore:
Private Sub LoadToolbarSettings()
Dim toolbars As SerializableDictionary(Of String, ToolbarUserSettings)
Try
Dim fileName As String = "myToolbarSettingsFile.xml"
toolbars = DeserializeFromFile(Of SerializableDictionary(Of String, ToolbarUserSettings))(fileName)
Catch ex As Exception
' nothing to do, let the form load as usual
Return
End Try
If toolbars.ContainsKey(tbar.Key) Then
Dim settings As ToolbarUserSettings = toolbars(tbar.Key)
tbar.IsMainMenuBar = settings.IsMainMenuBar
tbar.IsStockToolbar = settings.IsStockToolbar
tbar.ShowInToolbarList = settings.ShowInToolbarList
tbar.Visible = settings.Visible
tbar.DockedPosition = settings.DockedPosition
tbar.DockedRow = settings.DockedRow
tbar.DockedColumn = settings.DockedColumn
tbar.FloatingLocation = settings.FloatingLocation
tbar.FloatingSize = settings.FloatingSize
End If
This is the ToolbarUserSettings structure:
<Serializable()> Public Structure ToolbarUserSettings Dim DockedColumn As Integer Dim DockedPosition As DockedPosition Dim DockedRow As Integer Dim FloatingLocation As Point Dim FloatingSize As Size Dim IsMainMenuBar As Boolean Dim IsStockToolbar As Boolean Dim ShowInToolbarList As Boolean Dim Visible As Boolean End Structure
This is very complicated task, because it depend of different settings of your UltraToolbarManager. The best option for you could be to upgrade your solution with our latest available version.