OpenItemDialog issue with existing Project Item

290
0
05-05-2022 08:35 AM
StephenRhea_NV5
Occasional Contributor

I have a process where users can migrate a database from the ArcMap version of our tool to the Pro version. Users select their existing GDB using the OpenItemDialog, but if they've already added it to the project and select it from the Project section (highlighted), the Items collection is empty. Is there a way to access the selected Project Item? I'm using SDK 2.9.2.

StephenRhea_AximGeo_0-1651763706536.png

Selection code:

 

var picker = new ArcGIS.Desktop.Catalog.OpenItemDialog
{
    AlwaysUseInitialLocation = true,
    InitialLocation = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
    BrowseFilter = new ArcGIS.Desktop.Core.BrowseProjectFilter(DAML.Component.esri_browseDialogFilters_geodatabases_file),
    MultiSelect = false,
    Title = "Legacy File Geodatabase"
};

picker.ShowDialog();
var selection = picker.Items.FirstOrDefault();

if (selection == null)
{
    // *** Selecting an existing Project Item goes here.
    MessageBox.Show("No item selected");
}
else
{
    // Run migration
}

 

 

0 Replies