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);
}
}