yaten.jaiswal

Iselection_Event selectionchange is not working Please help

Discussion created by yaten.jaiswal on Nov 3, 2010
Hi I am trying to select new features and update name of the feature in datagrid Dynamically.
I used Iselection_events.
But Its giving me error on Iselectionevents_event.

My code is
  public IMxDocument mxd;
public IMap pmap;
public ESRI.ArcGIS.Carto.ISelectionEvents_Event mapsel;
public override void OnClick()
{
   pmap = mxd.FocusMap;
  
                pmap.ClearSelection();
                mxd.ActiveView.Refresh();
              //clear first selection
      mapsel = pmap as ESRI.ArcGIS.Carto.ISelectionEvents_Event; <---here "mapsel" value   
                                                                                                     =null... why its taking null?

    ESRI.ArcGIS.Carto.ISelectionEvents_SelectionChangedEventHandler m_selection = new ESRI.ArcGIS.Carto.ISelectionEvents_SelectionChangedEventHandler(this.OnSelectionChanged);
                mapsel.SelectionChanged += m_selection;  <----- here I am getting problem coz of null
                                                                                    value
  }

public void OnSelectionChanged()
{
///restof my code
messagebox.show(""+pmap.selectioncount);
   // to update my datagrid view
}

Please some one help me Why mapsel value is null.
pmap value is not null i checked that.
using 9.2
Thanks is Advance

Outcomes