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

How would implement a More.. option in a grid combo box

I'm using a Grid Grouping control and I have set the CellType for some of the cells to "ComboBox" but now I want to add a "More..." option to the bottom of the list. When this is selectd a dialog should be launched and the value returned from this should be used.
Also if the the cancel button is pressed on the dialog it needs to cancel the edit.

How would I go about do this

Thanks
Shane.

3 Replies

HA haneefm Syncfusion Team October 2, 2007 06:08 PM UTC

Hi Shane,

You can handle the CurrentCellShowingDropDown event of the grid and add the More option in DropDownList using the ListBoxPart.Items.Add method. Also you can handle the ListBoxPart.MouseDown event to popup your custom dialogbox to set your value in a cell. Below are the codes that show this task.

private void gridControl1_CurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs e)
{
GridComboBoxCellRenderer cr =(GridComboBoxCellRenderer) this.gridControl1.CurrentCell.Renderer;
if(cr!=null)
{
if (!cr.ListBoxPart.Items.Contains("More..."))
cr.ListBoxPart.Items.Add("More...");
cr.ListBoxPart.MouseDown += new MouseEventHandler(ListBoxPart_MouseDown);
}
}

void ListBoxPart_MouseDown(object sender, MouseEventArgs e)
{
ListBox listPart = sender as ListBox;
if (listPart.SelectedItem.Equals("More..."))
{
MessageBox.Show("More Options is selected, Please Popup your own UserDialog","User Notification");
}
}

void gridControl1_CurrentCellCloseDropDown(object sender, Syncfusion.Windows.Forms.PopupClosedEventArgs e)
{
GridComboBoxCellRenderer cr = (GridComboBoxCellRenderer)this.gridControl1.CurrentCell.Renderer;
if (cr != null)
{
cr.ListBoxPart.MouseDown -= new MouseEventHandler(ListBoxPart_MouseDown);
}
}

Best regards,
Haneef


SH Shane October 11, 2007 03:54 PM UTC

The events CurrentCellShowedDropDown and CurrentCellShowingDropDown aren't firing. Do I need to set something to activate these events?

>Hi Shane,

You can handle the CurrentCellShowingDropDown event of the grid and add the More option in DropDownList using the ListBoxPart.Items.Add method. Also you can handle the ListBoxPart.MouseDown event to popup your custom dialogbox to set your value in a cell. Below are the codes that show this task.

private void gridControl1_CurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs e)
{
GridComboBoxCellRenderer cr =(GridComboBoxCellRenderer) this.gridControl1.CurrentCell.Renderer;
if(cr!=null)
{
if (!cr.ListBoxPart.Items.Contains("More..."))
cr.ListBoxPart.Items.Add("More...");
cr.ListBoxPart.MouseDown += new MouseEventHandler(ListBoxPart_MouseDown);
}
}

void ListBoxPart_MouseDown(object sender, MouseEventArgs e)
{
ListBox listPart = sender as ListBox;
if (listPart.SelectedItem.Equals("More..."))
{
MessageBox.Show("More Options is selected, Please Popup your own UserDialog","User Notification");
}
}

void gridControl1_CurrentCellCloseDropDown(object sender, Syncfusion.Windows.Forms.PopupClosedEventArgs e)
{
GridComboBoxCellRenderer cr = (GridComboBoxCellRenderer)this.gridControl1.CurrentCell.Renderer;
if (cr != null)
{
cr.ListBoxPart.MouseDown -= new MouseEventHandler(ListBoxPart_MouseDown);
}
}

Best regards,
Haneef


J. J.Nagarajan Syncfusion Team December 31, 2007 08:03 PM UTC

Hi Shane ,

Sorry for the delay in getting back to you.

CurrentCellShowingDropDown event gets fired when the Combobox's DropDown is showing and CurrentCellShowedDropDown event gets fired after the expand the dropdown. Please refer to the attahced sample.

http://websamples.syncfusion.com/samples/Grid.Windows/F68701/main.htm

In this smaple both CurrentCellShowingDropDown and CurrentCellShowedDropDown events fired properly.

Please let me know if you have any other questions.

Regards,
Nagaraj


Loader.
Live Chat Icon For mobile
Up arrow icon