I am trying to join a table to a feature class in , and use the joined fields to create custom symobology based on the joined fields as the picture 1 below for Arcmap using ArcObjects. I am successfully joining the tables, and I can see the new fields in the layer when I open it's attribute table, however once successfully joined, and the code runs to specify the rederer I check the symbology and the entire category criteria gets hidden as picture 2. What could be causing this ? It is very strange, when I remove the code where the layer and table get joined, the symbology becomes correct using the 3 values I specified and it doesn't disappear.

Picture 1 [Picture 2[2]

Here my code

   protected override void OnClick()

    // code that gets all the proper objects
       var geoLayer=(IGeoFeatureLayer)ftrLayer;


      // method to join table and ftr class layer
     public void JoinTables(  IStandaloneTable pStTable,IFeatureLayer ftrLayer, IFeatureClass ftrClass){
       var pTabCollection = (IStandaloneTableCollection)arcMapApp.Document.FocusMap;
        if (pTabCollection.StandaloneTableCount == 0) {
        var pDispTable2 = (IDisplayTable)pStTable;
        var pTTable = pDispTable2.DisplayTable;
        IMemoryRelationshipClassFactory pMemRelFact;
        IRelationshipClass pRelClass;
        pMemRelFact = new MemoryRelationshipClassFactoryClass();
        pRelClass = pMemRelFact.Open("JoinedLayerAndTable", (IObjectClass)pTTable, "CL_ID",
          (IObjectClass)ftrClass, "ID", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);
        var dispRC = (IDisplayRelationshipClass)ftrLAyer;
        dispRC.DisplayRelationshipClass(pRelClass, esriJoinType.esriLeftOuterJoin); 

   public void CreateRenderer( IGeoFeatureLayer ftrLAyer){

        IUniqueValueRenderer renderer = new UniqueValueRendererClass();

        renderer.FieldCount = 3;
        renderer.Field[0] = "CATEGORY_NAME";
        renderer.Field[1] = "TYPE_NAME";
        renderer.Field[2] = "UUID";
        renderer.FieldDelimiter = "|";
        renderer.ColorScheme = "Custom";
        renderer.FieldType[0] = true;
        renderer.FieldType[1] = true;
        renderer.FieldType[2] = true;

        ILineSymbol smb = new SimpleLineSymbolClass();
        smb.Width = 2;
        IRgbColor clr = new RgbColorClass();
        clr.Red = 255;
        clr.Green = 0;
        clr.Blue = 0;
        smb.Color = clr;

        renderer.AddValue("XX1|INSUR|DWA", "www", (ISymbol)smb);
        pGeoFeatureLayer.Renderer = (IFeatureRenderer)renderer;
        var pUID = new UIDClass();
        pUID.Value = "{683C994E-A17B-11D1-8816-080009EC732A}";
        pGeoFeatureLayer.RendererPropertyPageClassID = pUID;

You mention that you are trying to join your table to the feature class, but your code below is doing the opposite.

pRelClass = pMemRelFact.Open("JoinedLayerAndTable", (IObjectClass)pTTable, "CL_ID", (IObjectClass)ftrClass, "ID", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);

Try the following:

public void JoinTables(IStandaloneTable pStTable, IFeatureLayer ftrLayer) {

    var ftLayerDispTable = (IDisplayTable)ftrLayer;
    var ftrDisplayTable = ftLayerDispTable.DisplayTable;

    var pDispTable2 = (IDisplayTable)pStTable;
    var pTTable = pDispTable2.DisplayTable;

    IMemoryRelationshipClassFactory pMemRelFact = new MemoryRelationshipClassFactoryClass();

    var pRelClass = pMemRelFact.Open("JoinedLayerAndTable", (IObjectClass) ftrDisplayTable, "ID",
        (IObjectClass) pTTable, "CL_ID", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToOne);

    var dispRc = (IDisplayRelationshipClass)ftrLayer;
    dispRc.DisplayRelationshipClass(pRelClass, esriJoinType.esriLeftOuterJoin);

You also need to use the following when setting the property page pUid.Value = "esriCartoUI.CombiUniqueValuePropertyPage"; then you need to call ActiveView.ContentsChanged(); not UpdateContents()

Edit: Another thing to note is when using fields from the Joined table in your renderer you need to specify the fully qualified field name in the join table.

  • You also need to use the following when setting the property page pUid.Value = "esriCartoUI.CombiUniqueValuePropertyPage"; then you need to call ActiveView.ContentsChanged(); not UpdateContents() – omarello Mar 8 '18 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.