This document is archived and information here might be outdated.  Recommended version.


Load ToolbarControl Items from File Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Load ToolbarControl Items from File Snippet

Load ToolbarControl items from a binary file.

[C#]
///<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);
}
[Visual Basic .NET]
'''<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

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Controls
  • ESRI.ArcGIS.System