private IActiveViewEvents_Event m_pActiveViewEvents; private void toolStripMenuItem2_Click(object sender, EventArgs e) { m_pActiveViewEvents = (IActiveViewEvents_Event)axMapControl1.ActiveView; //イベント ハンドラの登録 m_pActiveViewEvents.ViewRefreshed += new IActiveViewEvents_ViewRefreshedEventHandler(myViewRefreshed); //イベント ハンドラの登録解除 //m_pActiveViewEvents.ViewRefreshed -= new IActiveViewEvents_ViewRefreshedEventHandler(myViewRefreshed); } private void myViewRefreshed(IActiveView view, esriViewDrawPhase phase, object Data, IEnvelope envelope) { //処理内容を記述 }
Private m_pActiveViewEvents As IActiveViewEvents_Event Private Sub ToolStripMenuItem3_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripMenuItem3.Click 'オブジェクトのキャスト m_pActiveViewEvents = CType(axMapControl1.ActiveView, IActiveViewEvents_Event) 'イベント ハンドラの登録 AddHandler m_pActiveViewEvents.ViewRefreshed, AddressOf MyViewRefreshed 'イベント ハンドラの解除 'RemoveHandler m_pActiveViewEvents.ViewRefreshed, AddressOf MyViewRefreshed End Sub 'イベント実行時の処理メソッド Private Sub MyViewRefreshed(ByVal View As IActiveView, ByVal phase As esriViewDrawPhase, ByVal Data As Object, ByVal envelope As IEnvelope) '処理内容を記述 End Sub