Selected Layer Index

Jun 28, 2014 at 7:20 PM
Hello, dear all:
I want to find the index of selected layer to use it with the rest code. the example below shows what I want:
I want to find the value of i
    Dim fs As New FeatureSet
    Dim rrr As String
    fs = Map1.Layers.Item(0).DataSet
    rrr = "[STATE] = 'Johor'"
    Map1.GetFeatureLayers(0).SelectByAttribute(rrr)


    'fs.DataTable.Rows(i).Item("Temperature") = "OK"
    'fs.Save()
Jul 2, 2014 at 2:07 PM
I don't know if I get it right

first if you want to work with the selected layer you simply have to write the following:
fs=Map1.Layers.SelectedLayer.Dataset
I don't know why you need the index of the selected layer.

However to get it I would use this non elegant work around
For j as integer=0 to map1.layers.count-1
    If map1.layers(j).isSelected= true then
        i=j
        exit for
    End if
Next
But as I see you want to select some features and to change their "Temperature" attribute to "OK"
Dim Fsel as list (of Ifeature)
Fsel=Fs.SelectbyAttribute(rrr)

        For Each feat As IFeature In Fsel
            feat.DataRow.BeginEdit()
            feat.DataRow("Temperature") = "Ok"
            feat.DataRow.EndEdit()
        Next
Then you can save your modified feaureset

Hope this is what you wanted

Oscar