We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

combobox duplicate items

Thread ID:

Created:

Updated:

Platform:

Replies:

68652 Sep 26,2007 09:26 AM Oct 2,2007 07:07 PM Windows Forms 1
loading
Tags: GridControl
John
Asked On September 26, 2007 09:26 AM


Hi,

I have an editable combobox in my databoundgrid that allows the user to type in 'one' or 'two'. When I open up the table, the combobox list is populated with several instances of 'one' and 'two' that I don't need. Is there a way to remove these duplicate items from the list? Thanks!

haneefm [Syncfusion]
Replied On October 2, 2007 07:07 PM

Hi Coder12345,

You can handle the CurrentCellShowingDropDown event of the grid and remove the duplicated item using the gridComboBoxCellRenderer.ListBoxPart.Items.RemoveAt method. Here is a code snippet.

private void gridControl1_CurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs e)
{
GridComboBoxCellRenderer cr =(GridComboBoxCellRenderer) this.gridControl1.CurrentCell.Renderer;
if(cr!=null)
{
for (int i = 0; i < cr.ListBoxPart.Items.Count; i++)
{
for (int j = 0; j < cr.ListBoxPart.Items.Count; j++)
{
if (i != j && cr.ListBoxPart.Items[i].Equals(cr.ListBoxPart.Items[j]))
{
cr.ListBoxPart.Items.RemoveAt(i);
i--;
break;
}
}
}
}
}

Best regards,
Haneef

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;