IGxDialog Unable to Open Shapefiles

602
3
03-18-2020 06:44 AM
MatsHardy
Occasional Contributor

I have tried to use IGxDialog to open shapefiles by the codes below:

public static string getInputFile()
{
    string filename;
    IEnumGxObject enumGxObj;
    IGxObject gxObj;
    IGxObjectFilterCollection gxFilterColl;
    IGxDialog gxDialog;
    IGxObjectFilter gxObjFilter;

    filename = "";
    try
    {
        gxDialog = new GxDialog();
        gxFilterColl = (IGxObjectFilterCollection)gxDialog;
        gxDialog.AllowMultiSelect = false;
        gxObjFilter = new GxFilterShapefiles();
        //gxDialog.ObjectFilter = gxObjFilter;
        gxFilterColl.AddFilter(gxObjFilter, true);

        if (gxDialog.DoModalOpen(0, out enumGxObj))
        {
            gxObj = enumGxObj.Next();
            filename = gxObj.FullName;
            Logger.Debug("getInputFile filename = " + filename);
        }
    }
    catch (Exception ex)
    {
        Logger.Debug("getInputFile error: " + ex.Message);
    }

    return filename;
}

But when the GxDialog is opened, the shapefiles are not found.

But the shapefiles are found in ArcCatalog

Are there any problems on the codes? Thanks.

0 Kudos
3 Replies
GKmieliauskas
Esri Regular Contributor

Hi Mats,

On ArcGIS 10.3 your code works fine. What is your version of ArcGIS?

0 Kudos
MatsHardy
Occasional Contributor

Thanks. My ArcMap and ArcObjects are both 10.7.

0 Kudos
KenBuja
MVP Esteemed Contributor

Do you need to limit this to only shapefiles or can any featureclass get selected? What happens when you use the GxFilterFeatureClasses filter?

0 Kudos