IGxDialog Unable to Open Shapefiles

74
3
03-18-2020 06:44 AM
Highlighted
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.

Reply
0 Kudos
3 Replies
Highlighted
Regular Contributor

Hi Mats,

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

Reply
0 Kudos
Highlighted
Occasional Contributor

Thanks. My ArcMap and ArcObjects are both 10.7.

Reply
0 Kudos
Highlighted
MVP Honored Contributor

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

Reply
0 Kudos