private void axTOCControl1_ (  sender, ITOCControlEvents_ Event e)
                {
                    esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
                    IBasicMap map = null;     = null;
                      other = null;   index = null;
                    this.axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref  , ref other, ref index);

                    if (item == esriTOCControlItem.esriTOCControlItemLegendClass)
                    {
                        IFeature   S;
                         S =   as IFeature ;
                        ILegendClass plc = new LegendClassClass();
                        ILegendGroup plg = new LegendGroupClass();

                        if (other is ILegendGroup)
                        {
                            plg = (ILegendGroup)other;
                        }
                        plc = plg.get_Class((int)index);
                        ISymbol pSym;
                        pSym = plc.Symbol;
                        ISymbolSelector pSymbolSelector = new SymbolSelectorClass();
                        pSymbolSelector.AddSymbol(pSym);
                        bool b = pSymbolSelector.SelectSymbol(0);
                        if (b)
                        {
                            plc.Symbol = pSymbolSelector.GetSymbolAt(0);
                        }
                        axMapControl1.ActiveView.Refresh();
                        axTOCControl1.Refresh();
                    }
            }

运行效果:\"\"

收藏 打印