Imports System.Xml Imports Infragistics.Win.UltraWinToolbars Private Sub btnSaveHistory_Click(ByVal sender As Object, ByVal e As EventArgs) Dim writer As XmlTextWriter = Nothing Try writer = New XmlTextWriter("History.xml", Nothing) writer.Formatting = Formatting.Indented writer.Namespaces = False writer.WriteStartDocument() writer.WriteStartElement("History") ' Serialize the back history If Me.UltraToolbarsManager1.NavigationToolbar.BackHistoryCount > 0 Then writer.WriteStartElement("BackHistory") Dim backHistoryItem As NavigationHistoryItem For Each backHistoryItem In Me.UltraToolbarsManager1.NavigationToolbar.BackHistory writer.WriteStartElement("Item") writer.WriteString(backHistoryItem.Text) writer.WriteEndElement() Next writer.WriteEndElement() End If ' Serialize the current item Dim currentItem As NavigationHistoryItem = Me.UltraToolbarsManager1.NavigationToolbar.CurrentItem If Not currentItem Is Nothing Then writer.WriteStartElement("CurrentItem") writer.WriteString(currentItem.Text) writer.WriteEndElement() End If ' Serialize the forward history If Me.UltraToolbarsManager1.NavigationToolbar.ForwardHistoryCount > 0 Then writer.WriteStartElement("ForwardHistory") Dim forwardHistoryItem As NavigationHistoryItem For Each forwardHistoryItem In Me.UltraToolbarsManager1.NavigationToolbar.ForwardHistory writer.WriteStartElement("Item") writer.WriteString(forwardHistoryItem.Text) writer.WriteEndElement() Next writer.WriteEndElement() End If writer.WriteEndElement() writer.WriteEndDocument() writer.Flush() Catch ex As Exception MessageBox.Show("Could not serialize history\n\n" + ex.Message) Finally If Not writer Is Nothing Then writer.Close() End If End Try End Sub
using System.Xml; using Infragistics.Win.UltraWinToolbars; private void btnSaveHistory_Click(object sender, EventArgs e) { XmlTextWriter writer = null; try { writer = new XmlTextWriter("History.xml", null); writer.Formatting = Formatting.Indented; writer.Namespaces = false; writer.WriteStartDocument(); writer.WriteStartElement("History"); // Serialize the back history if (this.ultraToolbarsManager1.NavigationToolbar.BackHistoryCount > 0) { writer.WriteStartElement("BackHistory"); foreach (NavigationHistoryItem backHistoryItem in this.ultraToolbarsManager1.NavigationToolbar.BackHistory) { writer.WriteStartElement("Item"); writer.WriteString(backHistoryItem.Text); writer.WriteEndElement(); } writer.WriteEndElement(); } // Serialize the current item NavigationHistoryItem currentItem = this.ultraToolbarsManager1.NavigationToolbar.CurrentItem; if (currentItem != null) { writer.WriteStartElement("CurrentItem"); writer.WriteString(currentItem.Text); writer.WriteEndElement(); } // Serialize the forward history if (this.ultraToolbarsManager1.NavigationToolbar.ForwardHistoryCount > 0) { writer.WriteStartElement("ForwardHistory"); foreach (NavigationHistoryItem forwardHistoryItem in this.ultraToolbarsManager1.NavigationToolbar.ForwardHistory) { writer.WriteStartElement("Item"); writer.WriteString(forwardHistoryItem.Text); writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); } catch (Exception ex) { MessageBox.Show("Could not serialize history\n\n" + ex.Message); } finally { if (writer != null) writer.Close(); } }