本文整理汇总了C#中IFeatureClass.AddField方法的典型用法代码示例。如果您正苦于以下问题:C# IFeatureClass.AddField方法的具体用法?C# IFeatureClass.AddField怎么用?C# IFeatureClass.AddField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFeatureClass
的用法示例。
在下文中一共展示了IFeatureClass.AddField方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddField
public void AddField(IFeatureClass pFeatureClass,string fieldName,esriFieldType fieldType)
{
//如果存在不必添加字段,直接返回
if (pFeatureClass.FieldExistCheck(fieldName)) return;
var pField = new FieldClass();
var pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Name_2 = fieldName;
pFieldEdit.Type_2 = fieldType;
pFeatureClass.AddField(pFieldEdit);
}
示例2: AddField
private static void AddField(IFeatureClass featureClass, string fieldName, esriFieldType fieldType)
{
IField newField = new FieldClass();
((IFieldEdit)newField).Name_2 = fieldName;
((IFieldEdit)newField).Type_2 = fieldType;
var schemaLock = (ISchemaLock)featureClass;
try
{
// Get an exclusive schema lock to change the schema.
schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
featureClass.AddField(newField);
}
finally
{
//release the exclusive schema lock
schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
}
}
示例3: AddField
/// <summary>
/// 给图层添加字段
/// </summary>
/// <param name="strFieldCode"></param>
/// <param name="strFieldName"></param>
/// <param name="pFtCls"></param>
public static void AddField(string strFieldCode, string strFieldName, Type pType, int nLength,
IFeatureClass pFtCls)
{
try
{
///创建一新字段
esriFieldType fieldType = GetFieldType(pType);
IField pField = new FieldClass();
IFieldEdit pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Length_2 = nLength;
pFieldEdit.Name_2 = strFieldName;
pFieldEdit.AliasName_2 = strFieldName;
pFieldEdit.IsNullable_2 = true;
pFieldEdit.Required_2 = true;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
pFtCls.AddField(pField);
}
catch (Exception exp)
{
Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());
}
}
示例4: setFeatureClassFieldValue
private void setFeatureClassFieldValue(IFeatureClass feacls, string strfield, int val)
{
if(feacls.FindField(strfield)<0)
{
IField field = new FieldClass();
IFieldEdit fe = field as IFieldEdit;
fe.Name_2 = strfield;
fe.Type_2 = esriFieldType.esriFieldTypeInteger;
feacls.AddField(field);
}
int index = feacls.FindField(strfield);
IFeatureCursor cursor = feacls.Search(null, false);
IFeature fea = cursor.NextFeature();
while (fea != null)
{
fea.set_Value(index, val);
fea.Store();
fea = cursor.NextFeature();
}
}
示例5: AddAField
internal static bool AddAField(IFeatureClass pFeatureClass, string pFieldName, esriFieldType pFieldType, int pLength)
{
IField tField = new FieldClass();
IFieldEdit tFieldEdit = tField as IFieldEdit;
tFieldEdit.Type_2 = pFieldType;
tFieldEdit.Name_2 = pFieldName;
if (pFieldType == esriFieldType.esriFieldTypeString)
{
tFieldEdit.Length_2 = pLength;
}
ISchemaLock tSchemaLock = (ISchemaLock)pFeatureClass;
bool successful = false;
try
{
tSchemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
pFeatureClass.AddField(tField);
successful = true;
}
catch (Exception ex)
{
ServerLogger servLogger = new ServerLogger();
servLogger.LogMessage(ServerLogger.msgType.debug, "add field to output", 8000,
"Couldn't get schema lock to add field " + pFieldName + " to output!" + ex.Message);
}
finally
{
tSchemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
}
//logger.LogMessage(ServerLogger.msgType.debug, "AddAField", 99,
// "Added field: " + pFieldName+", success: "+successful.ToString());
return successful;
}
示例6: AddFields
/// <summary>
/// ��ͼ������ֶ�
/// </summary>
/// <param name="pFtCls"></param>
private void AddFields(IFeatureClass pFtCls)
{
try
{
IField pField = new FieldClass();
IFieldEdit pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Length_2 = 80;
pFieldEdit.Name_2 = "�������";
pFieldEdit.IsNullable_2 = true;
pFieldEdit.Required_2 = false;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
pFtCls.AddField(pField);
pField = new FieldClass();
pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Length_2 = 80;
pFieldEdit.Name_2 = "ͼ����";
pFieldEdit.IsNullable_2 = true;
pFieldEdit.Required_2 = false;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
pFtCls.AddField(pField);
pField = new FieldClass();
pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Length_2 = 80;
pFieldEdit.Name_2 = "�ֶ�����";
pFieldEdit.IsNullable_2 = true;
pFieldEdit.Required_2 = false;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
pFtCls.AddField(pField);
pField = new FieldClass();
pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Length_2 = 20;
pFieldEdit.Name_2 = "��ʶ��";
pFieldEdit.IsNullable_2 = true;
pFieldEdit.Required_2 = false;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
pFtCls.AddField(pField);
pField = new FieldClass();
pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Length_2 = 80;
pFieldEdit.Name_2 = "ͼ��2";
pFieldEdit.IsNullable_2 = true;
pFieldEdit.Required_2 = false;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
pFtCls.AddField(pField);
pField = new FieldClass();
pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Length_2 = 20;
pFieldEdit.Name_2 = "��ʶ��2";
pFieldEdit.IsNullable_2 = true;
pFieldEdit.Required_2 = false;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
pFtCls.AddField(pField);
pField = new FieldClass();
pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Length_2 = 50;
pFieldEdit.Name_2 = "����ͼ����";
pFieldEdit.IsNullable_2 = true;
pFieldEdit.Required_2 = false;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
pFtCls.AddField(pField);
pField = new FieldClass();
pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Length_2 = 255;
pFieldEdit.Name_2 = "��������";
pFieldEdit.IsNullable_2 = true;
pFieldEdit.Required_2 = false;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
pFtCls.AddField(pField);
pField = new FieldClass();
pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Length_2 = 50;
pFieldEdit.Name_2 = "�Ƿ�����";
pFieldEdit.IsNullable_2 = true;
pFieldEdit.Required_2 = false;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeSmallInteger;
pFtCls.AddField(pField);
pField = new FieldClass();
pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Length_2 = 255;
pFieldEdit.Name_2 = "˵��";
pFieldEdit.IsNullable_2 = true;
pFieldEdit.Required_2 = false;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
pFtCls.AddField(pField);
pField = new FieldClass();
pFieldEdit = (IFieldEdit)pField;
//.........这里部分代码省略.........
示例7: AddField
internal static void AddField(IFeatureClass featureClass, string name, esriFieldType type)
{
IFieldEdit field = new FieldClass();
field.Name_2 = name;
field.Type_2 = type;
featureClass.AddField(field);
}
示例8: AdicionarColuna
private static void AdicionarColuna(IField field, IFeatureLayer fLayer, IFeatureClass pFeatureClassShp, List<String> camposAdicionados)
{
IFieldEdit fldDomain = new FieldClass();
string aliasName = field.AliasName;
string fieldName = field.Name;
fldDomain.AliasName_2 = GetNomeNovo(aliasName, pFeatureClassShp, camposAdicionados);
fldDomain.Name_2 = GetNomeNovo(fieldName, pFeatureClassShp, camposAdicionados);
fldDomain.Editable_2 = true;
fldDomain.Length_2 = 254;
fldDomain.Type_2 = esriFieldType.esriFieldTypeString;
pFeatureClassShp.AddField(fldDomain);
camposAdicionados.Add(fldDomain.Name);
}