Help with select layer

Discussion created by katy2000 on Mar 21, 2011
Latest reply on Mar 21, 2011 by katy2000
Good morning, I have my combobox with all my dataframes , when I select a  dataframe in my list box are all its layers ,I have to selec just one layer of this list and make it active in the TOC . This is my code but when I chose one layer all the layer of the dataframe are actived. Any help is so appreciate than you

Private Sub lboLayers_Click()

Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Dim pTOC As IContentsView
Set pTOC = pMxDoc.ContentsView(0)
' Display tab usually
Set pMxDoc.CurrentContentsView = pTOC
' change tabs
Dim i As Integer
Dim pEnumLayer As IEnumLayer
Set pEnumLayer = pMxDoc.Maps.Item(cboDataFrames.ListIndex).Layers(, False)
Dim pLayer As ILayer
Set pLayer = pEnumLayer.Next
pTOC.RemoveFromSelectedItems pTOC.SelectedItem
Do While Not pLayer Is Nothing
pTOC.AddToSelectedItems pLayer
Set pLayer = pEnumLayer.Next
End Sub