Public g_sComboValue as String = "" ' global public variable used to pass selection to Windows form frmMyWinForm Public Class MyCombo_Tool Inherits ESRI.ArcGIS.Desktop.AddIns.ComboBox Private Shared aLayers As New List(Of String) Public Sub New() GetComboData() ' private sub that fills aLayers() with the contents to put in the combo, but does not fill the combobox. ' Code for this sub is not included in this example, but basically can be as simple as aLayers.Add("Item1") . . . End Sub Protected Overrides Sub OnSelChange(ByVal cookie As Integer) ' Exit if no item chosen from combobox If cookie = -1 Then Exit Sub Else g_sComboValue = myComboBox.Value ' grab the selection to pass to the next form Call FillCombo() ' FillCombo clears and refills the combo to clear the previous selection displayed in the editbox End If End Sub Protected Overrides Sub OnUpdate() Enabled = My.ArcMap.Application IsNot Nothing If g_sComboValue <> "" Then myComboBox.Finalize() End If End Sub Protected Overrides Sub Finalize() frmMyWinForm= New frmMyWinForm frmMyWinForm.ShowDialog() g_sComboValue = "" End Sub Private Sub FillCombo() ' fill combobox from array list Dim n As Integer = aLayers.Count Dim i As Integer = 0 myComboBox.Clear() For i = 0 To n - 1 myComboBox.Add(aLayers(i)) Next i End Sub
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.