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.

GridComboBoxCellRenderer setting the listbox items

Thread ID:

Created:

Updated:

Platform:

Replies:

52469 Nov 29,2006 04:56 AM Nov 30,2006 03:43 AM Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 29, 2006 04:56 AM

Hi,

I have derived from GridComboBoxCellRenderer and GridComboBoxCellModel to create a custom combobox cell. Now I want to fill the combobox dynamically with different items. I thought I can use the constructor of the GridComboBoxCellRenderer derived class to add the items. But this doesn't work:

public class ExampleCellRenderer : GridComboBoxCellRenderer
{
public ExampleCellRenderer(GridControlBase grid, GridCellModelBase cellModel)
: base(grid, cellModel)
{
ListBoxPart.Items.Clear();
ListBoxPart.Items.Add("ParameterValue2");
ListBoxPart.Items.Add("ParameterValue1");
}
....


Now when I click on the corresponding cell, I can't see the dropdown box with the items. Did I forgot something??

Thanks in advance,
Frank

Administrator [Syncfusion]
Replied On November 29, 2006 05:30 AM

Hi Frank,

You can override GridComboBoxCellRenderer. OnShowDropDown method and fill combobox cell dynamically with different items using ListBoxPart.Items property. Here is a code snippet to show this.

public class ExampleCellRenderer : GridComboBoxCellRenderer
{
public ExampleCellRenderer(GridControlBase grid, GridCellModelBase cellModel): base(grid, cellModel)
{
this.SupportsFocusControl = true;//cancel the editing in a cell
}

protected override void OnShowDropDown()
{
ListBoxPart.Items.Clear();
ListBoxPart.Items.Add("ParameterValue2");
ListBoxPart.Items.Add("ParameterValue1");
base.OnShowDropDown ();
}
}

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On November 29, 2006 09:40 AM

Hi Haneef,

thanks for your sample. I have still the problem that nothing happens when I click on the combobox dropdown button. I have attached a sample where you can see the strange behavior. Just click on the "EnumValue2" cell.

Appendix:
It is currently implemented that the combobox button is only visible when the user clicks on the corresponding cell.

Thanks in advance

SyncfusionCustomCell.zip

Administrator [Syncfusion]
Replied On November 30, 2006 03:43 AM

Hi Frank,

To show the dropdown button only for the current cell, you need to set the ShowButtons property to GridShowButtons.ShowCurrentCell. Here is a modified code snippet to show this.

void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
Element eDisplayElement = e.TableCellIdentity.DisplayElement;
if (eDisplayElement.Kind == DisplayElementKind.Record && eDisplayElement.ParentTable != null)
{
if (e.TableCellIdentity.Column != null && e.TableCellIdentity.Column.Name == "ObjectParameter")
{
GridRecordRow rec = e.TableCellIdentity.Table.DisplayElements[e.TableCellIdentity.RowIndex] as GridRecordRow;
if (rec != null)
{
MyData dr = rec.GetData() as MyData;
if (dr.ObjectParameter.GetType() == typeof(EnumParameter))
{
e.Style.CellType = "CustomCell";
e.Style.ShowButtons = Syncfusion.Windows.Forms.Grid.GridShowButtons.ShowCurrentCell;
}
}

}
}

Here is a modified sample.
http://www.syncfusion.com/Support/user/uploads/SyncfusionCustomCell_9455b56e.zip

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.

;