Home > Net >  The AE will object reference not set to an instance of an object
The AE will object reference not set to an instance of an object

Time:11-14

The HTML code is as follows, please bosses look:
Public partial class Form1: Form
{
[STAThread]
The static void Main ()
{
Application. EnableVisualStyles (); Application. SetCompatibleTextRenderingDefault (false); Application. The Run (new _click ());
}

Private ITOCControl2 m_tocControl=null;
Private IToolbarMenu m_menuMap=null;
Private IToolbarMenu m_menuLayer=null;
Private IMapControl3 m_mapControl=null;
//private ILayer layer;
//private esriTOCControlItem item;
Public _click ()
{
InitializeComponent ();

}


Private void axTOCControl1_OnMouseDown (object sender, ITOCControlEvents_OnMouseDownEvent e)
{
If (e.b utton!=2) return;
EsriTOCControlItem item=esriTOCControlItem. EsriTOCControlItemNone;
IBasicMap map=null;
ILayer layer=null;
The object other=null;
The object index=null;
m_tocControl. HitTest (e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
If (item==esriTOCControlItem. EsriTOCControlItemMap)
M_tocControl. SelectItem (map, null);
The else
M_tocControl. SelectItem (layer, null);
M_mapControl. CustomProperty=layer;
If (item==esriTOCControlItem. EsriTOCControlItemMap)
M_menuMap. PopupMenu (e.x, e.y, m_tocControl hWnd);
If (item==esriTOCControlItem. EsriTOCControlItemLayer)
M_menuLayer. PopupMenu (e.x, e.y, m_tocControl hWnd);
}
}
}

CodePudding user response:

M_tocControl this object is not new in structure or the load event new

CodePudding user response:

The object reference not set to an instance of an object is not instantiated, later I met this question will know what do you mean

CodePudding user response:

M_tocControl=new IMapControl3 ();
M_tocControl. HitTest (e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

CodePudding user response:

reference 3 floor mouse cried dead cat replies:
m_tocControl=new IMapControl3 ();
M_tocControl. HitTest (e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

I added this line of code and then prompt unable to create an abstract class or interface ". ESRI ArcGIS. Controls. IMapControl3 "instance of what's going on

CodePudding user response:

Is IMapControl3 interface, are you a third party or implements,
Is there the implementation class MapControl3

M_tocControl=new MapControl3 ();

IMapControl3 interface is

CodePudding user response:

reference 5 floor mouse cried dead cat replies:
IMapControl3 is an interface, you a third party or implements,
Is there the implementation class MapControl3

M_tocControl=new MapControl3 ();

Is IMapControl3 interface

I added a line of m_tocControl=new TOCControl () as ITOCControl2; This code seems ok
  •  Tags:  
  • C#
  • Related