Procedure

  1. Start ArcMap.
  2. Create a new UIButtonControl.
  3. Right-click the UIButtonControl and select View Source.
  4. Copy below code into the UIButtonControl's click event.

    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjectsDim strPathName As String 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects

    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjectsstrPathName = "D:"temp"yellowstone.mdb" ' Replace with the name of your Personal Geodatabase


  5. Modify the value of strPathName to reflect the location of your Personal Geodatabase.
  6. Copy the code below into the UIButtonControl's click event, immediately after the code you entered in Step 4.

    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjectsDim strData As String 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjectsstrData 
    = "AnnoRoad" ' Replace with the name of your annotation FeatureClass

  7. Modify the value of strData to point to the annotation Feature Class in your Personal Geodatabase.
  8. Copy the code below into the UIButtonControl's click event, immediately after the code you entered in Step 6.

    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects' Set up the WorkspaceFactory
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects

    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Dim pWorkspaceName As IWorkspaceName 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Set pWorkspaceName = New WorkspaceName 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjectspWorkspaceName.WorkspaceFactoryProgID 
    = "esricore.AccessWorkspaceFactory" 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjectspWorkspaceName.PathName 
    = strPathName 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Dim pDatasetName As IDatasetName 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Set pDatasetName = New FeatureClassName 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjectspDatasetName.Name 
    = strData 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Set pDatasetName.WorkspaceName = pWorkspaceName 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    ' Use a lightweight Name object to open the table.
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects

    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Dim pName As IName 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Set pName = pDatasetName  ' QI 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects

    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Dim pTable As ITable 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Set pTable = pName.Open 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Dim pFeatClass As IDataset 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Set pFeatClass = ptable 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Dim pFeatLay As IFeatureLayer 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    'IFDOGraphicsLayerFactory::OpenGraphicsLayer IS THE KEY to accessing the data! 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects

    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Dim pFDOGraphicsLayerFactory As IFDOGraphicsLayerFactory 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Set pFDOGraphicsLayerFactory = New FDOGraphicsLayerFactory 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    '*****************************************
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects

    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    ' Modify this line of code
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects

    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Set pFeatLay = pFDOGraphicsLayerFactory.OpenGraphicsLayer(pfeatclass.Workspace, Nothing"AnnoRoad"
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    '***************************************** 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects

    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    'Assign the name in the Table of Contents 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    pFeatLay.Name = pFeatClass.Name 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    ' Add the annotation to ArcMap
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects

    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Dim pMxDoc As IMxDocument 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Set pMxDoc = ThisDocument 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Dim pMap As IMap 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Set pMap = pMxDoc.ActiveView 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjectspMap.AddLayer pFeatLay 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Dim pAV As IActiveView 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Set pAV = pMap 
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
    Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjectspAV.Refresh

  9. Modify the third argument passed to the OpenGraphicsLayer method to point to the input annotation Feature Class.
  10. Test the code.

相关文章:

  • 2022-12-23
  • 2021-12-19
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2022-02-21
猜你喜欢
  • 2022-02-02
  • 2021-10-08
  • 2021-08-03
  • 2022-03-10
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
相关资源
相似解决方案