This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ESRI.ArcGIS.Snippets > Snippets > Load ToolbarControl Items from File Snippet (ArcObjects .NET 10.4 SDK) |
Load ToolbarControl items from a binary file.
///<summary>Load ToolbarControl items from a binary file.</summary> /// ///<param name="toolbarControl"> An IToolbarControl2 interface. Use the .Object property when passing a control in .NET. Example: axToolbarControl1.Object</param> ///<param name="fileName">A System.String that is the location on disk where to write the ToolbarControl. Example: "C:\temp\myItems"</param> /// ///<remarks>Call to load the ToolbarControl items out of a file. Typically this happens when an application starts and items are loaded from a user local profile.</remarks> public void LoadToolbarControlItemsFromFile(ESRI.ArcGIS.Controls.IToolbarControl2 toolbarControl, System.String fileName) { // Create a MemoryBlobStream ESRI.ArcGIS.esriSystem.IBlobStream blobStream=new ESRI.ArcGIS.esriSystem.MemoryBlobStreamClass(); // Get the IStream interface ESRI.ArcGIS.esriSystem.IStream stream=blobStream as ESRI.ArcGIS.esriSystem.IStream; // Load the stream from the file blobStream.LoadFromFile(fileName); // Load the stream into the ToolbarControl toolbarControl.LoadItems(stream); }
'''<summary>Load ToolbarControl items from a binary file.</summary> ''' '''<param name="toolbarControl"> An IToolbarControl2 interface. Use the .Object property when passing a control in .NET. Example: axToolbarControl1.Object</param> '''<param name="fileName">A System.String that is the location on disk where to write the ToolbarControl. Example: "C:\temp\myItems"</param> ''' '''<remarks>Call to load the ToolbarControl items out of a file. Typically this happens when an application starts and items are loaded from a user local profile.</remarks> Public Sub LoadToolbarControlItemsFromFile(ByVal toolbarControl As ESRI.ArcGIS.Controls.IToolbarControl2, ByVal fileName As System.String) ' Create a MemoryBlobStream Dim blobStream As ESRI.ArcGIS.esriSystem.IBlobStream=New ESRI.ArcGIS.esriSystem.MemoryBlobStreamClass() ' Get the IStream interface Dim stream As ESRI.ArcGIS.esriSystem.IStream=blobStream ' Load the stream from the file blobStream.LoadFromFile(fileName) ' Load the stream into the ToolbarControl toolbarControl.LoadItems(stream) End Sub