internal void UpdateDisplay()
 {
     if (!base.TextBoxReadOnly || this.DisplayMember == null || string.Equals(this.ValueMember, this.DisplayMember))
     {
         ValueToDisplayObjectConverter valueToDisplayObjectConverter = (this.ValueMemberConverter != null) ? this.ValueMemberConverter : new ToStringValueToDisplayObjectConverter();
         this.Text = ((this.SelectedValue == null || DBNull.Value == this.SelectedValue) ? string.Empty : valueToDisplayObjectConverter.Convert(this.SelectedValue).ToString());
         return;
     }
     if (this.SelectedValue != null && this.Picker != null)
     {
         object obj = null;
         ValueToDisplayObjectConverter valueToDisplayObjectConverter2 = (this.DisplayMemberConverter != null) ? this.DisplayMemberConverter : new ToStringValueToDisplayObjectConverter();
         if (this.Picker.SelectedObjects != null && this.Picker.SelectedObjects.Rows.Count > 0)
         {
             obj = this.Picker.SelectedObjects.Rows[0][this.DisplayMember];
         }
         else if (this.resolver != null && (this.SelectedValue is ADObjectId || this.ValueMemberPropertyDefinition != null) && !string.IsNullOrEmpty(this.SelectedValue.ToString()))
         {
             ADPropertyDefinition property = this.ValueMemberPropertyDefinition ?? ADObjectSchema.Id;
             this.resolver.ResolveObjectIds(property, new List <object>(new object[]
             {
                 this.SelectedValue
             }));
             base.UpdateBrowseButtonState();
         }
         else
         {
             obj = this.SelectedValue;
         }
         this.Text = ((obj == null) ? string.Empty : valueToDisplayObjectConverter2.Convert(obj).ToString());
         return;
     }
     this.Text = string.Empty;
 }
        private void resolver_ResolveObjectIdsCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            base.UpdateBrowseButtonState();
            ValueToDisplayObjectConverter valueToDisplayObjectConverter = (this.DisplayMemberConverter != null) ? this.DisplayMemberConverter : new ToStringValueToDisplayObjectConverter();
            object obj = null;

            if (this.resolver.ResolvedObjects != null && this.resolver.ResolvedObjects.Rows.Count > 0)
            {
                obj = this.resolver.ResolvedObjects.Rows[0][this.DisplayMember];
            }
            obj = (obj ?? this.SelectedValue);
            if (obj != null)
            {
                obj = valueToDisplayObjectConverter.Convert(obj);
            }
            this.Text = ((obj == null) ? string.Empty : obj.ToString());
        }
Exemple #3
0
        private void DataTableLoader_RefreshCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.suspendChangeNotification = true;
            object    selectedValue = this.SelectedValue;
            DataTable table         = (sender as DataTableLoader).Table;

            this.objectTable.Rows.Clear();
            foreach (object obj in table.Rows)
            {
                DataRow          dataRow          = (DataRow)obj;
                DataRow          dataRow2         = this.objectTable.NewRow();
                ConvertEventArgs convertEventArgs = new ConvertEventArgs(dataRow[this.ValueMember], dataRow[this.ValueMember].GetType());
                this.OnValueConvert(convertEventArgs);
                if (convertEventArgs.Value != null)
                {
                    dataRow2["ValueColumn"] = convertEventArgs.Value;
                    ValueToDisplayObjectConverter valueToDisplayObjectConverter = (this.ValueMemberConverter != null) ? this.ValueMemberConverter : new ToStringValueToDisplayObjectConverter();
                    dataRow2["DisplayColumn"] = (string.IsNullOrEmpty(this.DisplayMember) ? valueToDisplayObjectConverter.Convert(dataRow2["ValueColumn"]) : valueToDisplayObjectConverter.Convert(dataRow[this.DisplayMember]));
                    this.objectTable.Rows.Add(dataRow2);
                }
            }
            this.SelectedIndex             = -1;
            this.SelectedValue             = (this.delaySetSelectedValue ?? selectedValue);
            this.suspendChangeNotification = false;
        }