Hello,
I am trying to add and XY event layer through a data table generated from a datagridview in Winform. But when trying to make a string of data table object C# RuntimeBinderException occurs, that string converter has some invalid arguments. the code is mention below;
var st = Geoprocessing.MakeValueString(dT);
When I changed this to string expression,
string st = dT.ToString();
the code throws no exception but tool doesn't execute at all. code for tool execution is also mentioned below.
string st = dT.ToString();
var args = Geoprocessing.MakeValueArray(st, "Long", "Lat", "Settlement_m", "", "Settlement");
string tool_path = "MakeXYEventLayer_management";
System.Threading.CancellationTokenSource cts = new System.Threading.CancellationTokenSource();
var result = Geoprocessing.ExecuteToolAsync(tool_path, args, null, cts.Token, (event_name, o) => // implement delegate and handle events, o is message object
{
switch (event_name)
{
case "OnValidate": // stop execute if any warnings
if ((o as IGPMessage[]).Any(it => it.Type == GPMessageType.Warning))
cts.Cancel();
break;
case "OnProgressMessage":
string msg = string.Format("{0}: {1}", new object[] { event_name, (string)o });
System.Windows.MessageBox.Show(msg);
cts.Cancel();
break;
case "OnProgressPos":
string msg2 = string.Format("{0}: {1} %", new object[] { event_name, (int)o });
System.Windows.MessageBox.Show(msg2);
cts.Cancel();
break;
}
}, GPExecuteToolFlags.AddOutputsToMap|GPExecuteToolFlags.RefreshProjectItems);
var ret = await result;
cts = null;
I cannot give a file path for the XY Table because I am calculating Z-layer in runtime and adding it to the table before making the string of DataTable object. Any help would be appreciated.