public void button_Click(object sender, EventArgs e)
        {
            RuntimeServiceProvider serviceProvider = new RuntimeServiceProvider(this);
            object returnvalue = this.EditorInstance.EditValue(serviceProvider, serviceProvider, Value);

            UpdateValue(returnvalue);
        }
        private void LoadData()
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                if (this.ConverterInstance != null)
                {
                    if (!dataLoaded)
                    {
                        dropDown.Items.Clear();

                        //selected items??
                        dataLoaded = true;
                        RuntimeServiceProvider serviceProvider = new RuntimeServiceProvider(this);
                        foreach (object o in this.ConverterInstance.GetStandardValues(serviceProvider))
                        {
                            NameValueItem nvi = null;

                            if (o is NameValueItem)
                            {
                                nvi = o as NameValueItem;
                            }
                            else
                            {
                                nvi       = new NameValueItem();
                                nvi.Name  = o.ToString();
                                nvi.Value = o.ToString();
                            }
                            int pos = dropDown.Items.Add(nvi);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            this.Cursor = Cursors.Default;
        }
        protected override void UpdateValue(object newValue)
        {
            if (this.ConverterInstance != null)
            {
                if (!dataLoaded)
                {
                    //selected items??
                    List <string> selectedStrings = new List <string>();
                    if (newValue != null)
                    {
                        if (newValue.GetType() == typeof(string))
                        {
                            if (!string.IsNullOrEmpty(newValue.ToString()))
                            {
                                string strValue = newValue.ToString();
                                if (strValue.Contains(";"))
                                {
                                    char[] sep = new char[] { ';' };
                                    foreach (string strSep in strValue.Split(sep))
                                    {
                                        if (strSep != "")
                                        {
                                            selectedStrings.Add(strSep);
                                        }
                                    }
                                }
                                else
                                {
                                    //nur 1 element drin
                                    selectedStrings.Add(strValue);
                                }
                            }
                        }
                    }

                    dataLoaded = true;
                    RuntimeServiceProvider serviceProvider = new RuntimeServiceProvider(this);
                    foreach (object o in this.ConverterInstance.GetStandardValues(serviceProvider))
                    {
                        if (o is NameValueItem)
                        {
                            NameValueItem nvi = o as NameValueItem;
                            ListViewItem  lvi = new ListViewItem(nvi.Name);
                            lvi.Tag      = nvi;
                            lvi.ImageKey = nvi.ItemType;
                            listview.Items.Add(lvi);

                            ListViewItem.ListViewSubItem slvi = new ListViewItem.ListViewSubItem();
                            slvi.Text = nvi.Description;
                            lvi.SubItems.Add(slvi);

                            if (ConverterInstance != null)
                            {
                                if (!ConverterInstance.IsValid(serviceProvider, nvi))
                                {
                                    lvi.ForeColor = Color.Gray;
                                }

                                //select a default value, if only one selection is allowed
                                if ((selectedStrings.Count == 0) && !withCheckboxes)
                                {
                                    if (listview.SelectedItems.Count == 0)
                                    {
                                        //ITypeDescriptorContext context = serviceProvider.GetService(typeof(ITypeDescriptorContext)) as ITypeDescriptorContext;

                                        if (ConverterInstance.IsValid(serviceProvider, nvi))
                                        {
                                            lvi.Selected = true;
                                        }
                                    }
                                }
                            }

                            if (selectedStrings.Contains(nvi.ToString()))
                            {
                                if (withCheckboxes)
                                {
                                    lvi.Checked = true;
                                }
                                else
                                {
                                    lvi.Selected = true;
                                }
                            }
                        }
                        else
                        {
                            NameValueItem nvi = new NameValueItem();
                            nvi.Name  = o.ToString();
                            nvi.Value = o.ToString();

                            ListViewItem lvi = new ListViewItem(o.ToString());
                            lvi.Tag      = nvi;
                            lvi.ImageKey = o.ToString();
                            listview.Items.Add(lvi);

                            if (selectedStrings.Contains(nvi.ToString()))
                            {
                                if (withCheckboxes)
                                {
                                    lvi.Checked = true;
                                }
                                else
                                {
                                    lvi.Selected = true;
                                }
                            }
                        }
                    }

                    //if only one item is available, go to the next wizard page, if there is only 1 visible control on the wizard page
                    if (listview.Items.Count == 1)
                    {
                        int controlcount = 0;
                        foreach (Control control in this.WizardPage.Controls)
                        {
                            if (control.Visible)
                            {
                                if (control.GetType() == typeof(Panel))
                                {
                                    //ignore the button panel
                                }
                                else
                                {
                                    controlcount++;
                                }
                            }
                        }
                        if (controlcount == 1)
                        {
                            //I'm the only one control on the wizard page
                            if (this.WizardPage.Wizard.NextPage != null)
                            {
                                this.WizardPage.Wizard.OnNext();

                                //this.WizardPage.Wizard.GotoPage(this.WizardPage.Wizard.NextPageFromPage(this.WizardPage));
                            }
                        }
                    }
                }
            }

            base.SetValue(newValue);
        }
        protected override void UpdateValue(object newValue)
        {
            if (this.ConverterInstance != null)
            {
                if (!dataLoaded)
                {
                    //selected items??
                    List<string> selectedStrings = new List<string>();
                    if (newValue != null)
                    {
                        if (newValue.GetType() == typeof(string))
                        {
                            if (!string.IsNullOrEmpty(newValue.ToString()))
                            {
                                string strValue = newValue.ToString();
                                if (strValue.Contains(";"))
                                {
                                    char[] sep = new char[] { ';' };
                                    foreach (string strSep in strValue.Split(sep))
                                    {
                                        if (strSep != "")
                                        {
                                            selectedStrings.Add(strSep);
                                        }
                                    }
                                }
                                else
                                {
                                    //nur 1 element drin
                                    selectedStrings.Add(strValue);
                                }
                            }
                        }
                    }

                    dataLoaded = true;
                    RuntimeServiceProvider serviceProvider = new RuntimeServiceProvider(this);
                    foreach (object o in this.ConverterInstance.GetStandardValues(serviceProvider))
                    {
                        if (o is NameValueItem)
                        {
                            NameValueItem nvi = o as NameValueItem;
                            ListViewItem lvi = new ListViewItem(nvi.Name);
                            lvi.Tag = nvi;
                            lvi.ImageKey = nvi.ItemType;
                            listview.Items.Add(lvi);

                            ListViewItem.ListViewSubItem slvi = new ListViewItem.ListViewSubItem();
                            slvi.Text = nvi.Description;
                            lvi.SubItems.Add(slvi);

                            if (ConverterInstance != null)
                            {
                                if (!ConverterInstance.IsValid(serviceProvider, nvi))
                                {
                                    lvi.ForeColor = Color.Gray;
                                }

                                //select a default value, if only one selection is allowed
                                if ((selectedStrings.Count == 0) && !withCheckboxes)
                                {
                                    if (listview.SelectedItems.Count == 0)
                                    {
                                        //ITypeDescriptorContext context = serviceProvider.GetService(typeof(ITypeDescriptorContext)) as ITypeDescriptorContext;

                                        if (ConverterInstance.IsValid(serviceProvider, nvi))
                                        {
                                            lvi.Selected = true;
                                        }
                                    }
                                }
                            }

                            if (selectedStrings.Contains(nvi.ToString()))
                            {
                                if (withCheckboxes)
                                {
                                    lvi.Checked = true;
                                }
                                else
                                {
                                    lvi.Selected = true;
                                }
                            }
                        }
                        else
                        {
                            NameValueItem nvi = new NameValueItem();
                            nvi.Name = o.ToString();
                            nvi.Value = o.ToString();

                            ListViewItem lvi = new ListViewItem(o.ToString());
                            lvi.Tag = nvi;
                            lvi.ImageKey = o.ToString();
                            listview.Items.Add(lvi);

                            if (selectedStrings.Contains(nvi.ToString()))
                            {
                                if (withCheckboxes)
                                {
                                    lvi.Checked = true;
                                }
                                else
                                {
                                    lvi.Selected = true;
                                }
                            }
                        }
                    }

                    //if only one item is available, go to the next wizard page, if there is only 1 visible control on the wizard page
                    if (listview.Items.Count == 1)
                    {
                        int controlcount = 0;
                        foreach (Control control in this.WizardPage.Controls)
                        {
                            if (control.Visible)
                            {
                                if (control.GetType() == typeof(Panel))
                                {
                                    //ignore the button panel
                                }
                                else
                                {
                                    controlcount++;
                                }
                            }
                        }
                        if (controlcount == 1)
                        {
                            //I'm the only one control on the wizard page 
                            if (this.WizardPage.Wizard.NextPage != null)
                            {
                                this.WizardPage.Wizard.OnNext();

                                //this.WizardPage.Wizard.GotoPage(this.WizardPage.Wizard.NextPageFromPage(this.WizardPage));
                            }
                        }
                    }
                }
            }

            base.SetValue(newValue);
        }
 public void button_Click(object sender, EventArgs e)
 {
     RuntimeServiceProvider serviceProvider = new RuntimeServiceProvider(this);
     object returnvalue = this.EditorInstance.EditValue(serviceProvider, serviceProvider, Value);
     UpdateValue(returnvalue);
 }
        private void LoadData()
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                if (this.ConverterInstance != null)
                {
                    if (!dataLoaded)
                    {
                        dropDown.Items.Clear();

                        //selected items??
                        dataLoaded = true;
                        RuntimeServiceProvider serviceProvider = new RuntimeServiceProvider(this);
                        foreach (object o in this.ConverterInstance.GetStandardValues(serviceProvider))
                        {
                            NameValueItem nvi = null;

                            if (o is NameValueItem)
                            {
                                nvi = o as NameValueItem;
                            }
                            else
                            {
                                nvi = new NameValueItem();
                                nvi.Name = o.ToString();
                                nvi.Value = o.ToString();

                            }
                            int pos = dropDown.Items.Add(nvi);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            this.Cursor = Cursors.Default;
        }