Hi every body.
I'm developing an add-on to Map3D 2013, using .net4.0.
To show non-spatial data of feature sources, I firstly used Map3D built-in form using "_+MapDataTable" command and passing my layer definition as it's argument, which works fine, but the problem was that the data table is editable (all fields but "OBJECTID"), but I need to allow user to view or view and edit on a specified layer. So I decided to develop my custom data view form, and fill data using the below code (based on MgFeatureReader class):
private void UpdateTable()
{
if (SelectedLayer == null)
{
return;
}
if (SelectedLayer == "")
{
return;
}
if (!AcMapMap.GetCurrentMap().GetLayers().Contains(SelectedLayer))
{
return;
}
using (DocumentLock lck = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
{
Data = new System.Data.DataTable();
Data.Columns.Clear();
DataRow[] fldrs = FieldsTable.Select("layername='" + SelectedLayer + "'");
foreach (DataRow fldr in fldrs)
{
Data.Columns.Add(fldr["name"].ToString(), typeof(string));
}
int propertyCount;
String propertyName;
MgLayerBase layer = AcMapMap.GetCurrentMap().GetLayers().GetItem(SelectedLayer);
MgFeatureReader featureReader = layer.SelectFeatures(new MgFeatureQueryOptions());
while (featureReader.ReadNext())
{
DataRow ndr = Data.NewRow();
propertyCount = featureReader.GetPropertyCount();
for (int i = 0; i < propertyCount; i++)
{
propertyName = featureReader.GetPropertyName(i);
if (!Data.Columns.Contains(propertyName))
{
continue;
}
ndr[propertyName] = featureReader.GetString(propertyName);
}
Data.Rows.Add(ndr);
}
dataGridView_list.DataSource = Data;
}
}
This code works without any error, but it takes so long time, based on number of fields of the data layer. (1 to 30 seconds even more!!!).
But Map3D's built-in interface, works rapid enough and without any delay.
Does anyone knows about this? or, is there any solution to make Map3D's built-in data view interface read-only? I'm really confused!!!
Any help would be appreciated greatly.