ArcObjects Library Reference  (Carto)    

esriCarto IFeatureLayer Example

[Visual Basic 6.0]
Sub AddLayer()
' creates a FeatureLayer from a shapefile and adds to the map in ArcMap
  Dim pShpWksFact As IWorkspaceFactory
  Dim pFeatWks As IFeatureWorkspace
  Dim pFeatClass As IFeatureClass
  Dim pFeatLayer As IFeatureLayer
  Dim pDataSet As IDataset
  Dim pMxDoc As IMxDocument
  Dim pMap As IMap
  Set pShpWksFact = New ShapefileWorkspaceFactory
  Set pFeatWks = pShpWksFact.OpenFromFile("D:\Data\CentreCounty", 0)
  Set pFeatClass = pFeatWks.OpenFeatureClass("roads")
  Set pFeatLayer = New FeatureLayer
  Set pFeatLayer.FeatureClass = pFeatClass
  Set pDataSet = pFeatClass
  pFeatLayer.Name = pDataSet.Name
  Set pMxDoc = Application.Document
  Set pMap = pMxDoc.FocusMap
  pMap.AddLayer pFeatLayer
End Sub

[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button Language Filter in the upper-left corner of the page.