ArcDataBinding.FieldPropertyDescriptor.SetValue C# (CSharp) Méthode

SetValue() public méthode

Sets the value of the component to a different value.
If the field this instance represents does not have a coded value domain, this method simply sets the given value and stores the row within an edit operation. If the field does have a coded value domain, the method first needs to check that the given value is valid. If we are displaying the coded values, the value passed to this method will be a string and we will need to see if it is one of the names in the cv domain. If we are not displaying the coded values, we will still need to check that the given value is within the domain. If the value is not within the domain, an error will be displayed and the method will return. Note that the string comparison is case sensitive.
public SetValue ( object component, object value ) : void
component object The component (an IRow) with the property value /// that is to be set.
value object The new value.
Résultat void
    public override void SetValue(object component, object value)
    {
      IRow givenRow = (IRow)component;

      if (null != cvDomain)
      {
        // This field has a coded value domain
        if (!useCVDomain)
        {
          // Check value is valid member of the domain
          if (!((IDomain)cvDomain).MemberOf(value))
          {
            System.Windows.Forms.MessageBox.Show(string.Format(
              "Value {0} is not valid for coded value domain {1}", value.ToString(), ((IDomain)cvDomain).Name));
            return;
          }
        }
        else
        {
          // We need to convert the string value to one of the cv domain values
          // Loop through all the values until we, hopefully, find a match
          bool foundMatch = false;
          for (int valueCount = 0; valueCount < cvDomain.CodeCount; valueCount++)
          {
            if (value.ToString() == cvDomain.get_Name(valueCount))
            {
              foundMatch = true;
              value = valueCount;
              break;
            }
          }

          // Did we find a match?
          if (!foundMatch)
          {
            System.Windows.Forms.MessageBox.Show(string.Format(
              "Value {0} is not valid for coded value domain {1}", value.ToString(), ((IDomain)cvDomain).Name));
            return;
          }
        }
      }
      givenRow.set_Value(wrappedFieldIndex, value);

      // Start editing if we aren't already editing
      bool weStartedEditing = false;
      if (!wkspcEdit.IsBeingEdited())
      {
        wkspcEdit.StartEditing(false);
        weStartedEditing = true;
      }

      // Store change in an edit operation
      wkspcEdit.StartEditOperation();
      givenRow.Store();
      wkspcEdit.StopEditOperation();

      // Stop editing if we started here
      if (weStartedEditing)
      {
        wkspcEdit.StopEditing(true);
      }

    }