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. Image for the cookie policy date
close icon

Remove items from drop down list

I'm looking to remove a specific item from drop down lists based on certain criteria. The only place that I've found to interact with the contents of the drop down list(GridTableDropDownListCellRenderer.ListControlPart.Items) is read-only, which means I am unable to remove items from the list. I'm hoping there is a way to circumvent that. Any help is appreciated.

Thanks.


3 Replies

JJ Jisha Joy Syncfusion Team April 1, 2011 11:28 AM UTC

Hi Erik,

You need to remove the item from the data source binded to the dropdown instead of removing it from the ListBox control part.


Please let me know if you have any questions.

Regards,
Jisha



EE Erik Ernst April 27, 2011 11:10 PM UTC

Unfortunately, if I remove the item from the data source it is removed from all drop down lists in a particular column, and not just the lists that meet a specified criteria within that column. If there is no other way around this limitation then I guess I will have to stick to the less elegant way I have it right now which shows a message box if a user tries to select the item and then ignores their selection. Obviously, I would rather hide the item from the list, but I understand if there's no way around it. I appreciate the help.

Thanks,
Erik



AA Arulraj A Syncfusion Team May 6, 2011 07:10 AM UTC

Hi Erik,

Thanks for the update.

You can achieve the required behavior by handling TableControlCurrentCellShowingDropDown event and remove the specific item for a particular row. Please refer the following sample where the items are customized for row 4 only.

this.gridGroupingControl1.TableControlCurrentCellShowingDropDown += new GridTableControlCurrentCellShowingDropDownEventHandler(gridGroupingControl1_TableControlCurrentCellShowingDropDown);

void gridGroupingControl1_TableControlCurrentCellShowingDropDown(object sender, GridTableControlCurrentCellShowingDropDownEventArgs e)
{
if (e.TableControl.CurrentCell.RowIndex == 4 )
{
GridComboBoxCellRenderer rend = e.TableControl.CurrentCell.Renderer as GridComboBoxCellRenderer;
rend.ListBoxPart.Items.Remove("Black");
rend.ListBoxPart.Items.Remove("Yellow");
}
}

Sample:
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GGC_6336874573.zip

Regards,
Arulraj.A



Loader.
Live Chat Icon For mobile
Up arrow icon