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.

Remove items from drop down list

Thread ID:

Created:

Updated:

Platform:

Replies:

98779 Mar 29,2011 06:21 PM May 6,2011 03:10 AM Windows Forms 3
loading
Tags: GridControl
Erik Ernst
Asked On March 29, 2011 06:21 PM

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.


Jisha Joy [Syncfusion]
Replied On April 1, 2011 07:28 AM

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


Erik Ernst
Replied On April 27, 2011 07:10 PM

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


Arulraj A [Syncfusion]
Replied On May 6, 2011 03:10 AM

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



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.

;