This document is archived and information here might be outdated.  Recommended version.


INetworkLoader.PutEnabledDisabledFieldName Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > NetworkAnalysis > ESRI.ArcGIS.NetworkAnalysis > Interfaces > IN > INetworkLoader Interface > INetworkLoader.PutEnabledDisabledFieldName Method
ArcGIS Developer Help

INetworkLoader.PutEnabledDisabledFieldName Method

Specifies the enabled/disabled field for the specified feature class.

[Visual Basic .NET]
Public Sub PutEnabledDisabledFieldName ( _
    ByVal featureClassName As String, _
    ByVal enabledDisabledFieldName As String _
)
[C#]
public void PutEnabledDisabledFieldName (
    string featureClassName,
    string enabledDisabledFieldName
);
[C++]
HRESULT PutEnabledDisabledFieldName(
  BSTR featureClassName,
  BSTR enabledDisabledFieldName
);
[C++]
Parameters
featureClassName [in]

featureClassName is a parameter of type BSTR enabledDisabledFieldName [in]
enabledDisabledFieldName is a parameter of type BSTR

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

Every feature class in your network must have a field that determines whether a feature is enabled or disabled. Enabled and disabled features affect how flow and the trace results are determined.

It is strongly recommended to use the default name for the enabled/disabled field. If you do not make a call to PutEnabledDisabledFieldName for a feature class, then the NetworkLoader assumes that you wish to use the default name for the enabled/disabled field. The default name for the enabled/disabled field can be obtained from the DefaultEnabledField property on the INetworkLoaderProps interface.

If you specify an existing field to use as the enabled/disabled field, it is best to check that this field is of the correct type and domain to be used as an enabled/disabled field. You can check this by calling the CheckEnabledDisabledField method. You also have the option of resetting all values in the existing field to True, or preserving the existing values. See the help for the PreserveEnabledValues property for more details.

If the field specified does not exist, then the NetworkLoader will automatically add it to the feature class when it builds the network, populating all values in this field with the value True.

[C#]

The following code demonstrates using the default enabled/disabled field name and checking the enabled/disabled field before calling PutEnabledDisabledFieldName (See the Note below). It also sets the PreserveEnabledValues property to True:

INetworkLoaderProps networkLoaderProps = networkLoader2 as INetworkLoaderProps;
string defEDFld = networkLoaderProps.DefaultEnabledField;
esriNetworkLoaderFieldCheck ckFld = networkLoader2.CheckEnabledDisabledField("FeatureClassName", defEDFld);
switch (ckFld)
{
case esriNLFCValid:
case esriNLFCNotFound:
networkLoader2.PutEnabledDisabledFieldName("FeatureClassName", "EnabledDisabledName")
break;
default:
Console.WriteLine("The field " + defEDFld + " could not be used as an enabled/disabled field.");
return;
break;
}
networkLoader2.PreserveEnabledValues = true;

Note: In reality, this code (with exception to the call to PreserveEnabledValues) would not be necessary, since in the absence of calls to PutEnabledDisabledFieldName for a feature class, the NetworkLoader assumes that you wish to use the default enabled/disabled field for that feature class. The code is provided here for illustrative purposes.

[Visual Basic .NET]

The following code demonstrates using the default enabled/disabled field name and checking the enabled/disabled field before calling PutEnabledDisabledFieldName (See the Note below). It also sets the PreserveEnabledValues property to True:

Dim networkLoaderProps As INetworkLoaderProps = CType(networkLoader2, INetworkLoaderProps)
Dim defEDFld As String = networkLoaderProps.DefaultEnabledField
Dim ckFld As esriNetworkLoaderFieldCheck = networkLoader2.CheckEnabledDisabledField("FeatureClassName", defEDFld)
Select Case ckFld
Case esriNLFCValid, esriNLFCNotFound
networkLoader2.PutEnabledDisabledFieldName("FeatureClassName", "EnabledDisabledName")
Case Else
Console.WriteLine("The field " & defEDFld & " could not be used as an enabled/disabled field.")
Exit Sub
End Select
networkLoader2.PreserveEnabledValues = True

Note: In reality, this code (with exception to the call to PreserveEnabledValues) would not be necessary, since in the absence of calls to PutEnabledDisabledFieldName for a feature class, the NetworkLoader assumes that you wish to use the default enabled/disabled field for that feature class. The code is provided here for illustrative purposes.

See Also

INetworkLoader Interface