Select from Selected

658
5
10-18-2011 09:14 PM
ColinBird
New Contributor
I have written a basic feature classs editor that loops through selected features editing attributes one at a time. I was hoping to highlight the current feature from the selected features. A simple process to do by hand. I already set properties and show the attribute table via ITableSelectionColor ITableProperty ITableProperties and ITableWindow. Does anyone know a method to highlight a feature in an attribute table of seleted features?
0 Kudos
5 Replies
GregRieck
Occasional Contributor III
Hi Colin,
Here is some sample code. I have not tested this specific code, but the logic should be there. Basically you need to get the stand alone table, then use the stand alone table to instantiate ITableFields.
ITableFields tablefields = "IStandAloneTable" as ITableFields.
IFieldInfo3 fieldinfo3 = null;
for(int x = 0; x < tablefields.FieldCount; x++)
{
    fieldinfo3 = tableinfo.FieldInfo as IFieldInfo3;
    if(tablefields.Field.Name == "somefield")
      fieldinfo3.Highlight = true;
    ......
}


G
0 Kudos
ColinBird
New Contributor
Hi Grieck

Thanks for the reply. I have been elsewhere. The snip you left works fine and it gave me some ideas but it highlights the field. I was wanting to highlight the feature (row) using the secondary selection colour.

Colin
0 Kudos
ColinBird
New Contributor
'Some code to illustrate

Public Sub FlashIt()
  Dim pDoc As IMxDocument
  Dim pLayer As IFeatureLayer
  Dim pFeat As IFeature
  Dim pFeatureSeln As IFeatureSelection
  Dim pSelectionSet As ISelectionSet
  Dim pCursor As IFeatureCursor
  Dim aa As Integer
 
  Set pDoc = ThisDocument
  Set pLayer = pDoc.FocusMap.Layer(0)
  Set pFeatureSeln = pLayer
 
  ShowTable pLayer
 
  Set pSelectionSet = pFeatureSeln.SelectionSet
  pSelectionSet.Search Nothing, True, pCursor
  Set pFeat = pCursor.NextFeature
  aa = 0
  Do Until pFeat Is Nothing
    aa = aa + 1
    If (aa = 4) Then
      FlashFeature pFeat
      ' Highlight pFeat Rather than flash this feature I would like to highlight it in the
    End If
    Set pFeat = pCursor.NextFeature
  Loop
End Sub
Private Sub ShowTable(pLayer As ILayer)
  Dim pTabWin As ITableWindow
  Set pTabWin = New TableWindow
  Set pTabWin.FeatureLayer = pLayer
  Set pTabWin.Application = Application
  pTabWin.ShowSelected = True
  pTabWin.TableSelectionAction = esriNoAction
  pTabWin.Show True
End Sub
Private Sub FlashFeature(pFeature As IFeature)
  Dim pMxApp As IMxApplication
  Dim pIdObj As IIdentifyObj
  Dim pFeatIdObj As IFeatureIdentifyObj
 
  Set pMxApp = Application
  Set pFeatIdObj = New FeatureIdentifyObject
  pFeatIdObj.Feature = pFeature
  Set pIdObj = pFeatIdObj
  pIdObj.Flash pMxApp.Display
End Sub
0 Kudos
GregRieck
Occasional Contributor III
Hi,

Did you ever figure this out?

Greg
0 Kudos
GregRieck
Occasional Contributor III
Hi, This is what I was able to get working in my solution for selecting a row and changing the color. You need to add the stdole DLL to your project references.

Then after your "pTabWin.Show True" add the following code. Basically the window needs to be shown before you can select from it and change the color. In this example I've hard code the OID parameter, i.e. 3.


        ITableWindow3 tw3 = tw3.ActiveTableWindow as ITableWindow3;
        ITableControl3 tc3 = tw3.TableControl as ITableControl3;
        if (tc3 != null)
          tc3.SetCurrentRow(true, 3);
        IRgbColor rgbcolor = new RgbColorClass();
        rgbcolor.Red = 255;
        rgbcolor.Green = 255;
        rgbcolor.Blue = 0;
        IColor color = rgbcolor as IColor;
        tc3.SetCellFont(3, "", color, null, null);


Greg
0 Kudos