call ComboBox method from MapTool

262
4
08-20-2020 05:58 PM
JackKelley1
New Contributor II

In the SDK's Examples\MapExploration\GetMapCoordinates.cs, the map coordinates become available in HandleMouseDownAsync(...).

Afterwards, still in HandleMouseDownAsync(...), I need to invoke a method defined in a ComboBox, something like:

public void SearchXY (double x, double y) 
{ this.queryRows = this.database.Query(x, y); UpdateCombo(); }

How can I obtain a reference to this ComboBox?

Or is an event needed?

Tags (1)
0 Kudos
4 Replies
GintautasKmieliauskas
Regular Contributor
JackKelley1
New Contributor II

Thanks Gintautus, That code looks promising. Will the DAML need to be changed?

I wish that the SDK did the work for me. The add-in's default Module singleton would provide access by some "FindItem" method.

0 Kudos
GintautasKmieliauskas
Regular Contributor

Hi Jack,

It is possible to get your combobox in ArcGIS Pro way, but there is no samples with combobox.

var comboBox = FrameworkApplication.GetPlugInWrapper("your_combox_id");

I have checked it returns wrapper with CommandType value ComboBox, but I don't what to do next. For example, cast to your combobox class or something like that. You can investigate that way.

JackKelley1
New Contributor II

Yes Gintautas, that code in Combo Box Reload showed the way.

The add-in has classes Module1, MapTool1ComboBox1, plus my own Database.

The required call from MapTool1 works fine and is simply

Module1.Current.ComboBox1.SearchXY(x, y);

Visual Studio made some suggestions to simplify the code (and the Config.daml needed no change).

In brief, the additions / modifications were:

Module1:

public ComboBox1 ComboBox1 { get; set; } = null;

ComboBox1

public ComboBox1()
{
    if (Module1.Current == null) return;
    Module1.Current.ComboBox1 = this;
    this.database = new Database();
    //UpdateCombo();
}

0 Kudos