I would like to know what is the easiest way to set the starting location of a data dialog to a IWorkspace?
My problem is that basically I do not want a connection (.sde file) for the users. I want to set the starting location to a workspace connected via IPropertySet. Is it possible?
This is related: Force a new AddDataDialog to open at a defined directory path but does not help.
EDIT:
following Kirk's suggestion, here's a code snippet. This does not work.
public static IDataset OpenDatasetDialog(IWorkspace workspace,int handle)
{
var workspaceName = (IWorkspaceName)((IDataset)workspace).FullName);
var gxDatabase = new GxdatabaseClass();
gxDatabase.WorkspaceName = workspaceName;
// we need to set a different variable as .NET runtime does not allow ref parameters with casts
object gxObj = (object)gxDatabase;
IGxDialog openDialog = new GxDialogClass();
openDialog.RememberLocation = false;
openDialog.set_StartingLocation(ref gxObj);
var filterColletion = (IGxObjectFilterCollection)openDialog;
filterColletion.AddFilter(new GxFilterTablesAndFeatureClassesClass(), true);
openDialog.AllowMultiSelect = false;
IEnumGxObject datasets = null;
IDataset dataset = null;
if (openDialog.DoModalOpen(0, out datasets) && datasets != null)
{
IGxObject gxObject = datasets.Next();
if (gxObject is IGxDataset)
{
IGxDataset gxDataset = (IGxDataset)gxObject;
dataset = gxDataset.Dataset;
}
else
throw new ArgumentException();
}
openDialog.InternalCatalog.Close();
return dataset;
}