This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ESRI.ArcGIS.Snippets > Snippets > Get Selected Geodataset in Contents View Snippet (ArcObjects .NET 10.4 SDK) |
Returns a reference to the currently selected GeoDataset in the given contents view.
///<summary>Returns a reference to the currently selected GeoDataset in the given contents view.</summary> /// ///<param name="currentContentsView">An IContentsView interface.</param> /// ///<returns>An IGeoDataset interface or Nothing if not found.</returns> /// ///<remarks></remarks> public ESRI.ArcGIS.Geodatabase.IGeoDataset GetSelectedGeodatasetInContentsView(ESRI.ArcGIS.ArcMapUI.IContentsView currentContentsView) { if (currentContentsView != null && currentContentsView.SelectedItem is ESRI.ArcGIS.Geodatabase.IGeoDataset) { ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset=(ESRI.ArcGIS.Geodatabase.IGeoDataset)currentContentsView.SelectedItem; // Explicit Cast return geoDataset; } return null; }
'''<summary>Returns a reference to the currently selected GeoDataset in the given contents view.</summary> ''' '''<param name="currentContentsView">An IContentsView interface.</param> ''' '''<returns>An IGeoDataset interface or Nothing if not found.</returns> ''' '''<remarks></remarks> Public Function GetSelectedGeodatasetInContentsView(ByVal currentContentsView As ESRI.ArcGIS.ArcMapUI.IContentsView) As ESRI.ArcGIS.Geodatabase.IGeoDataset If Not currentContentsView Is Nothing AndAlso TypeOf currentContentsView.SelectedItem Is ESRI.ArcGIS.Geodatabase.IGeoDataset Then Dim geoDataset As ESRI.ArcGIS.Geodatabase.IGeoDataset=CType(currentContentsView.SelectedItem, ESRI.ArcGIS.Geodatabase.IGeoDataset) ' Explicit Cast Return geoDataset End If Return Nothing End Function