<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to use DefaultValues on IFields for FeatureClasses? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-use-defaultvalues-on-ifields-for/m-p/521213#M14044</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You have to call IRowSubtypes::InitDefaultValues in order to set default values on the new row.&amp;nbsp; There is an example in the developer help topic for this method.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Mar 2012 12:41:32 GMT</pubDate>
    <dc:creator>NeilClemmons</dc:creator>
    <dc:date>2012-03-08T12:41:32Z</dc:date>
    <item>
      <title>How to use DefaultValues on IFields for FeatureClasses?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-use-defaultvalues-on-ifields-for/m-p/521212#M14043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I create a FeatureClass with some different Fields. After that I add a couple of Features to this FeatureClass.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;One of the fields, called CreationDate, shall have every time the same value for all added Features where the other Fields-values will differ from each other.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would really like to make use of the DefaultValue2 Property of the IField Interface to store that specific creation Date "automatically" for all features being added.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In my mind I would expect that when I add/ create a new feature in the FeatureClass and I do not set a value explicity for the Field "CreationDate" the DefaultValue will be used and stored on that Field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The Problem is, after all, the Field "CreationDate" is still empty as I never had set it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here some code I use for:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;//Creating Fields to be added List&amp;lt;IField&amp;gt; fieldsToBeAdded = new...; addFields.Add(GISUtilities.GISUtilities.createNewField(tmp, esriFieldType.esriFieldTypeString, tmp, false, 100, dateString));&amp;nbsp; IFields fields = new FieldsClass(); IFieldsEdit fieldsEdit = (IFieldsEdit)fields;&amp;nbsp; //Add all Fields to be Added foreach (IField addField in fieldsToBeAdded) { &amp;nbsp;&amp;nbsp;&amp;nbsp; fieldsEdit.AddField(addField); }&amp;nbsp; featureClass= workspace.CreateFeatureClass(featureString, fields, null, null, abc.FeatureType, abc.ShapeFieldName, null);&amp;nbsp; //some Code which sets values explicity for all Fields except the field CreationDate (I debugged it, it is not set by mistake)&amp;nbsp; //Add Features using IFeatureCursor insertCursorAuswahl.InsertFeature(featureBufferAuswahl);&amp;nbsp;&amp;nbsp; //After this statement I would expect the defaultValue Assigned, but my debug shows me still empty fields value = ""&amp;nbsp;&amp;nbsp; //StopEditing and so workspaceEdit.StopEditing(true);&amp;nbsp; insertCursor.Flush(); return featureClass; &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Mar 2012 11:39:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-use-defaultvalues-on-ifields-for/m-p/521212#M14043</guid>
      <dc:creator>SebastianKrings</dc:creator>
      <dc:date>2012-03-08T11:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to use DefaultValues on IFields for FeatureClasses?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-use-defaultvalues-on-ifields-for/m-p/521213#M14044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You have to call IRowSubtypes::InitDefaultValues in order to set default values on the new row.&amp;nbsp; There is an example in the developer help topic for this method.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Mar 2012 12:41:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-use-defaultvalues-on-ifields-for/m-p/521213#M14044</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2012-03-08T12:41:32Z</dc:date>
    </item>
  </channel>
</rss>

