static void TextEdit_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
        {
            TextEdit       currentTextEdit = sender as TextEdit;
            ListBoxControl currentListBox  = currentTextEdit.Tag as ListBoxControl;

            if (e.NewValue != null)
            {
                int iSelectedIndex = currentListBox.FindString(e.NewValue.ToString());
                if (iSelectedIndex >= 0 && iSelectedIndex < currentListBox.Items.Count)
                {
                    currentListBox.SelectedIndex = iSelectedIndex;
                }
            }
        }
コード例 #2
0
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                if (context == null)
                {
                    throw new System.ArgumentNullException("context");
                }
                if (provider == null)
                {
                    throw new System.ArgumentNullException("provider");
                }

                System.Windows.Forms.Design.IWindowsFormsEditorService iwindowsFormsEditorService = provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)) as System.Windows.Forms.Design.IWindowsFormsEditorService;
                if (iwindowsFormsEditorService != null)
                {
                    ListBoxControl listBoxControl = new ListBoxControl(iwindowsFormsEditorService);
                    listBoxControl.Items.Add("None");
                    foreach (string s1 in enumFields)
                    {
                        listBoxControl.Items.Add(s1);
                    }

                    string s2 = (string)value;
                    if (System.String.IsNullOrEmpty(s2))
                    {
                        listBoxControl.SelectedIndex = 0;
                    }
                    else
                    {
                        listBoxControl.SelectedIndex = listBoxControl.FindString(s2);
                    }
                    iwindowsFormsEditorService.DropDownControl(listBoxControl);

                    string s3 = System.String.Empty;
                    int    i  = listBoxControl.SelectedIndex;
                    if (i > 0)
                    {
                        s3 = listBoxControl.Items[i] as string;
                    }
                    return(s3);
                }
                return(value);
            }
コード例 #3
0
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                if (context == null)
                    throw new System.ArgumentNullException("context");
                if (provider == null)
                    throw new System.ArgumentNullException("provider");

                System.Windows.Forms.Design.IWindowsFormsEditorService iwindowsFormsEditorService = provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)) as System.Windows.Forms.Design.IWindowsFormsEditorService;
                if (iwindowsFormsEditorService != null)
                {
                    ListBoxControl listBoxControl = new ListBoxControl(iwindowsFormsEditorService);
                    listBoxControl.Items.Add("None");
                    foreach(string s1 in enumFields)
                        listBoxControl.Items.Add(s1);

                    string s2 = (string)value;
                    if (System.String.IsNullOrEmpty(s2))
                        listBoxControl.SelectedIndex = 0;
                    else
                        listBoxControl.SelectedIndex = listBoxControl.FindString(s2);
                    iwindowsFormsEditorService.DropDownControl(listBoxControl);
                    
                    string s3 = System.String.Empty;
                    int i = listBoxControl.SelectedIndex;
                    if (i > 0)
                        s3 = listBoxControl.Items[i] as string;
                    return s3;
                }
                return value;
            }