在ArcGIS Engine中,要得到某一个类,首要要获取工作空间,然后进入工作空间再得到相应的东西,我
们定义一个函数用来获取个人数据库的路径
public string WsPath()
{
string WsFileName="";
OpenFileDialog OpenFile = new OpenFileDialog();
OpenFile.Filter = "个人数据库(MDB)|*.mdb";
DialogResult DialogR = OpenFile.ShowDialog();
if (DialogR == DialogResult.Cancel)
{
}
else
{
WsFileName = OpenFile.FileName;
}
return WsFileName;
}
要获取要素类,首先要进入
private void button2_Click(object sender, EventArgs e)
{
string WsName = WsPath();
if (WsName != "")
{
IWorkspaceFactory pWsFt = new AccessWorkspaceFactoryClass();
IWorkspace pWs = pWsFt.OpenFromFile(WsName, 0);
IEnumDataset pEDataset = pWs.get_Datasets(esriDatasetType.esriDTAny);
IDataset pDataset = pEDataset.Next();
while (pDataset != null)
{
if (pDataset.Type ==esriDatasetType.esriDTFeatureClass)
{
FeatureClassBox.Items.Add(pDataset.Name);
}
//如果是数据集
else if (pDataset.Type == esriDatasetType.esriDTFeatureDataset)
{
IEnumDataset pESubDataset = pDataset.Subsets;
IDataset pSubDataset = pESubDataset.Next();
while (pSubDataset != null)
{
FeatureClassBox.Items.Add(pSubDataset.Name);
pSubDataset = pESubDataset.Next();
}
}
pDataset = pEDataset.Next();
}
}
FeatureClassBox.Text = FeatureClassBox.Items[0].ToString();
}
判断要素是否被编辑
IDatasetEdit.IsBeingEdited