예제 #1
0
        public void SelectByValue(ListBox lb, StandardValuesTypeConverterBase standardValuesConverter, object val)
        {
            selectedIndexChangedDisabled = true;
            try
            {
                lb.SelectedItem = null;
                foreach (ListItem item in lb.Items)
                {
                    if (standardValuesConverter != null)
                    {
                        if (standardValuesConverter.SelectListItemByValue(item, val))
                        {
                            lb.SelectedItem = item;
                            break;
                        }
                    }

                    if (val != null && val.Equals(item.Value))
                    {
                        lb.SelectedItem = item;
                        break;
                    }
                }
            }
            finally
            {
                selectedIndexChangedDisabled = false;
            }
        }
예제 #2
0
        protected virtual StandardValuesTypeConverterBase ResolveStandardValuesTypeConverter(object value)
        {
            TypeConverter typeConverter = value == null ? null : TypeDescriptor.GetConverter(value);
            StandardValuesTypeConverterBase standardValuesConverter = typeConverter as StandardValuesTypeConverterBase;

            return(standardValuesConverter);
        }