1

How do I disable the Start Editing button in ArcMap when an added ArcSDE database version is the default?

IMxDocument pMxdoc = m_application.Document as IMxDocument;
IMap pMap = pMxdoc.FocusMap;
ILayer pLayer = pMap.get_Layer(0);
int count = pMap.LayerCount;
if (count == 0)
{
 MessageBox.Show("Layer not found in ArcMap");
}
 else
{
 IFeatureLayer pFlayer = pLayer as IFeatureLayer;
 IFeatureClass pFclass = pFlayer.FeatureClass;
 IFeatureDataset pFDSet = pFclass.FeatureDataset;
 IWorkspace pWorkspace = ((IDataset)pMxdoc.ActiveView.FocusMap.Layer[0]).Workspace;
 IVersion version = pWorkspace as IVersion;
 string versioname = version.VersionName;
 IEditor editor = getEditor();
 ICommandItem item = GetCommandItemByName("{59D2AFD0-9EA2-11D1-9165-0080C718DF97}");                    
 ICommand cmd = item as ICommand;
 string name = item.Name;
 int indexval = item.Index;
 bool value = Enabled();
 //ToolbarControl1.SetBuddyControl(MapControl1);                
 //IToolbarPalette toolbarPalette = ToolbarControl1.GetItem(item.Index) as IToolbarPalette; 
 if (versioname != "SDE.DEFAULT")
 {
   cmd.Enabled = value;                        
 }
  if (versioname == "SDE.DEFAULT")
 {
  Enabled();
  MessageBox.Show("Database in SDE Default version so that Start Editing option Disabled");
  }
 }   
  • 1
    If your goal is to restrict editing, it seems like it would be easier to accomplish this using permissions. 'All employees can connect to all three versions. Only the geodatabase administrator can edit data when connected to the DEFAULT version and post to the DEFAULT version. When employees connect through the Base or Cases versions, they can edit any datasets to which they have been granted the required dataset permissions.' see the help. – Kirk Kuykendall Sep 11 '17 at 16:49
0

As commented by @KirkKuykendall:

If your goal is to restrict editing, it seems like it would be easier to accomplish this using permissions. 'All employees can connect to all three versions. Only the geodatabase administrator can edit data when connected to the DEFAULT version and post to the DEFAULT version. When employees connect through the Base or Cases versions, they can edit any datasets to which they have been granted the required dataset permissions.' see the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.