I am trying to create a basic form using ArcObjects (VB.NET) to view in ArcMap 10.0. I have created the form using the designer but can't view it in ArcMap. I have created a button that will call the form and show it using form.show()
method but seems it does nothing when I click it.
How can I show GUI forms in ArcMap? I thought by creating a separate button to call the form will work?
Form code:
Public Class ArcGISForm
Public Sub New(ByVal hook As Object)
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.Hook = hook
End Sub
Private m_hook As Object
Public Property Hook() As Object
Get
Return m_hook
End Get
Set(ByVal value As Object)
m_hook = value
End Set
End Property
''' <summary>
'''creating and disposing the user interface class for the dockable window.
''' </summary>
Public Class AddinImpl
Inherits ESRI.ArcGIS.Desktop.AddIns.DockableWindow
Private m_windowUI As ArcGISForm
Protected Overrides Function OnCreateChild() As System.IntPtr
m_windowUI = New ArcGISForm(Me.Hook)
Return m_windowUI.Handle
End Function
Protected Overrides Sub Dispose(ByVal Param As Boolean)
If m_windowUI IsNot Nothing Then
m_windowUI.Dispose(Param)
End If
MyBase.Dispose(Param)
End Sub
End Class
Private Sub ArcGISForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm2 As New ArcMapAddin2.ArcGISForm(Me.Hook)
frm2.Hide()
End Sub
End Class
Here is how I am trying to call the form, from a button.
Public Class showform
Inherits ESRI.ArcGIS.Desktop.AddIns.Button
Public Sub New()
End Sub
Protected Overrides Sub OnClick()
Dim frm As New ArcMapAddin2.ArcGISForm(Me.Hook)
frm.Show()
End Sub
Protected Overrides Sub OnUpdate()
End Sub
End Class
Any ideas how I can open the form from the button? Or should I follow a different method?
UPDATE:
I have tried the following and still doesn't work:
Dim oForm As ArcGISForm
oForm = New ArcGISForm(Me.Hook)
oForm.ShowDialog()
oForm = Nothing
All it does is close ArcMap down. When I click the button.
-
try ShowDialog method. perhaps your form is hidden or beneath the ArcMap's form. I did not reviewed the whole code in detail, but do a simple experiment. Create a brand new form, without anything and try to do a showdialog on it. It should work.George Silva– George Silva2016年01月14日 20:29:14 +00:00Commented Jan 14, 2016 at 20:29
-
Hi @user65266 Seems like you misplaced your password. Maybe you want to join these two accounts.Kersten– Kersten2016年01月16日 21:17:31 +00:00Commented Jan 16, 2016 at 21:17
-
Hi .not sure how that happened. I fixed the issue by using VB standard form template rather than the ESRI Arcobjects one.Daz– Daz2016年01月18日 14:42:36 +00:00Commented Jan 18, 2016 at 14:42
-
I think my accounts are merged now.Daz– Daz2016年01月18日 15:26:48 +00:00Commented Jan 18, 2016 at 15:26
1 Answer 1
This worked. As long as i didnt use the ESRI ArcMap Addin form template it was ok. With ArcMap addin forms it always gives an error about using Hooks. When you call the form must have a hook variable passed through it or something. Didnt quite understand it. But using the standard VB.net form was ok.
Dim oform As New ArcMapAddin2.Form2()
oform.ShowDialog()
oform = Nothing
As long as you dont add any Hooks in the form then the above code should work if you need to call the form from a button in Arcmap.
Explore related questions
See similar questions with these tags.