Hello,
We have a variety of datasets in our SDE that need fields auto-populated when a feature's created. My current implementation works fine for FeatureLayers because I can access the Table object when new map views are accessed. I work through all the FeatureLayers in the Map's TOC and subscribe them to events as needed. Unfortunately for StandaloneTables I can't directly subscribe them because they can't be converted to a Table object. Is there any way around this?
Any help is greatly appreciated. My current implementation is as follows:
Module1.cs:
protected static void OnActiveMapViewChangedEvent(ActiveMapViewChangedEventArgs args)
{
if (MapView.Active != null)
{
EditorExtension.UnregisterRowEvents();
foreach (FeatureLayer layer in MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>())
{
EditorExtension.RegisterLayerEvents(layer);
}
foreach(StandaloneTable standaloneTable in MapView.Active.Map.GetStandaloneTablesAsFlattenedList())
{
EditorExtension.RegisterStandaloneTableEvents(standaloneTable);
}
}
}
EditorExtension.cs:
public static void RegisterStandaloneTableEvents(StandaloneTable standaloneTable)
{
QueuedTask.Run(() =>
{
MapMember mapMember = standaloneTable as MapMember;
CIMStandardDataConnection cimDataConnection = mapMember.GetDataConnection() as CIMStandardDataConnection;
if (cimDataConnection.WorkspaceConnectionString.Contains("SDE.DEFAULT"))
{
_rowCreatedTokens.Add(RowCreatedEvent.Subscribe(OnRowCreatedEvent, standaloneTable)); // ERROR: cannot convert standalonetable to table
}
});
}
Solved! Go to Solution.
Hi,
StandaloneTable has method GetTable() witch returns table object.
_rowCreatedTokens.Add(RowCreatedEvent.Subscribe(OnRowCreatedEvent, standaloneTable.GetTable()));
Hi,
StandaloneTable has method GetTable() witch returns table object.
_rowCreatedTokens.Add(RowCreatedEvent.Subscribe(OnRowCreatedEvent, standaloneTable.GetTable()));
Oh geez of course, I even do this with the FeatureLayers. One of those days I guess!
Thank you so much for your help. Marked as solution.