Add any Windows component to ArcGIS toolbar (VB. NET source code)

Source: Internet
Author: User

Compile ArcGISProgramYou often need to add components such as textbox to the toolbar,

This article describes how to add any Windows component to ArcGIS toolbar.

Write a new commandcustomcontrol class that implements the icommand interface and the itoolcontrol interface,

Add a Windows component to reference the commandcustomcontrol form,

Such as label, Textbox, and ComboBox, and then input it to commandcustomcontrol.

The call method is as follows:

 Dim ptext as new commandcustomcontrol
Ptext. customcontrol = textbox1
Axtoolbarcontrol1.additem (ptext)
Dim pcombo as new commandcustomcontrol
Pcombo. customcontrol = combobox1
Axtoolbarcontrol1.additem (pcombo)

The following section describesSource code:

imports ESRI. arcGIS. systemui
imports system. windows. forms
'''


''' custom command, you can add components such as label and textbox to the toolbar
'''
''' to implement the icommand interface and itoolcontrol interface, add a Windows component, such as label, Textbox, and ComboBox, to reference the commandcustomcontrol form, and then input it to commandcustomcontrol.
public class commandcustomcontrol
implements itoolcontrol
implements icommand

# region "variables and attributes"
Public pcompnotify as icompletionpolicy
private m_control as control
'''


''' Input control, such as label, textbox, etc.
'''
'''
'''
''' controls can be input here, alternatively, you can create a new control in the constructor. Of course, it is best to pass in the control outside, so that you can design the control outside and capture the control-related events
property customcontrol () as Control
Get
return m_control
end get
set (byval value as control)
m_control = value
end set
end property
# End Region

''' <Summary>
''' Constructor
''' </Summary>
''' <Remarks> </remarks>
Sub new ()
M_control = new label
M_control.text = "label"
End sub

# Region "Implementing itoolcontrol"
Public readonly property hwnd () as integer implements ESRI. ArcGIS. systemui. itoolcontrol. hwnd
Get
Return m_control.handle
End get
End Property

Public Function ondrop (byval bartype as ESRI. ArcGIS. systemui. esricmdbartype) as Boolean implements ESRI. ArcGIS. systemui. itoolcontrol. ondrop
If bartype = esricmdbartype. esricmdbartypetoolbar then
Return true
End if
End Function

Public sub onfocus (byval complete as ESRI. ArcGIS. systemui. icompletionnotify) implements ESRI. ArcGIS. systemui. itoolcontrol. onfocus
Pcompnotify = complete
End sub
# End Region

# Region "Implementing icommand"
Public readonly property Bitmap () as integer implements ESRI. ArcGIS. systemui. icommand. Bitmap
Get

End get
End Property

Public readonly property caption () as string implements ESRI. ArcGIS. systemui. icommand. Caption
Get

End get
End Property

Public readonly property category () as string implements ESRI. ArcGIS. systemui. icommand. Category
Get

End get
End Property

Public readonly property checked () as Boolean implements ESRI. ArcGIS. systemui. icommand. Checked
Get
Return true
End get
End Property

Public readonly property enabled () as Boolean implements ESRI. ArcGIS. systemui. icommand. Enabled
Get
Return true
End get
End Property

Public readonly property helpcontextid () as integer implements ESRI. ArcGIS. systemui. icommand. helpcontextid
Get

End get
End Property

Public readonly property helpfile () as string implements ESRI. ArcGIS. systemui. icommand. helpfile
Get

End get
End Property

Public readonly property message () as string implements ESRI. ArcGIS. systemui. icommand. Message
Get

End get
End Property

Public readonly property name () as string implements ESRI. ArcGIS. systemui. icommand. Name
Get

End get
End Property

Public sub onclick () implements ESRI. ArcGIS. systemui. icommand. onclick

End sub

Public sub oncreate (byval hook as object) implements ESRI. ArcGIS. systemui. icommand. oncreate

End sub

Public readonly property tooltip () as string implements ESRI. ArcGIS. systemui. icommand. tooltip
Get

End get
End Property
# End Region

End Class

download the complete program:/files/wall/testcommandcustomcontrol.rar

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.