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.

ListControlPart and FilterBar

Thread ID:

Created:

Updated:

Platform:

Replies:

61668 May 30,2007 01:58 PM Jun 4,2007 01:14 PM Windows Forms 4
loading
Tags: GridControl
Miki Watts
Asked On May 30, 2007 01:58 PM

I'm using GDBG.

I have a drop down cell with custom model and renderer, that displays a ListControlPart while arranging the columns.

I would like to provide a filter bar in the grid that shows up when the drop down is opened, but the WireGrid function in GridFilterBar only take GridDataBoundGrid, and not GridControl, which is what I get from the ListControlPart.Grid.

Is there a way to do something like this?

Alternatively, when opening the drop down list, using the AutoComplete style, I can type in the grid cell, and have the drop down list automatically jump to the matching value. My problem is that when choosing the row, the value in the cell is the valueMember.

I'd like to be able to insert a different value in the grid cell, specifically the displayMember. For example, I have a list of banks, with their code and name. If I set the name to be the value member, then the grid cell will search and display the bank name, but I want it to display the bank code instead.

Any way to do that ?

haneefm [Syncfusion]
Replied On May 30, 2007 08:14 PM

Hi Miki,

One way you can do this by deriving the GridComboBoxCellRenderer and override the GetDisplayText to set your display text .Here is a code snippet

public class MyComboBoxCellModel : GridComboBoxCellModel
{
public MyComboBoxCellModel(GridModel grid): base(grid)
{}
public override GridCellRendererBase CreateRenderer(GridControlBase control)
{
return new MyComboBoxCellRenderer(control, this);
}
}

public class MyComboBoxCellRenderer : GridComboBoxCellRenderer
{
public MyComboBoxCellRenderer(GridControlBase grid, GridCellModelBase cellModel): base(grid, cellModel)
{
this.SupportsFocusControl = false;
}
public override string GetDisplayText()
{
return "YourTextHere";
}
}

Best regards,
Haneef

Miki Watts
Replied On May 31, 2007 04:22 AM

I should have mentioned that I'm deriving the renderer from GridDropDownGridListControlCellRenderer, as I need to also customize the display of the popup grid.

GetDisplayText wasn't called at all, but OnSetControlText was, and I was able to give it different text to display in the parent grid cell, but when leaving the grid cell, it just cleared.

haneefm [Syncfusion]
Replied On May 31, 2007 05:15 PM

Hi Miki,

Issue 1: change the grid settings

If you want to change the GridListControl settings in a custom grid cell then you need to override the CreateListControlPart method and retrun your own grid list control. Here is a code snippet

protected override GridListControl CreateListControlPart()
{
GridListControl grid = new GridListControl();
grid.Grid.Model.Options.AlphaBlendSelectionColor = Color.Red;
return grid;
}

If you want to modify the DropDown datasource in a grid cell then you need to handle the CurrentCellShowingDropDown event and set the ListControlPart.DataSource to new datasource.

Issue 2: Keep the text in a grid cell.

One way you can do this by setting the style.Text in onSetControlText event. Below is a code snippet.

protected override void OnSetControlText(string text)
{
if( text == "parentName5" || text == "parentName4" )
{
int index = base.FindItem(text,false,0,true);
this.TextBox.Text = "Selected Index " + Convert.ToString(index);
this.Grid.Model[RowIndex,ColIndex].Text = this.TextBox.Text;
}
else
base.OnSetControlText(text);
}

Here is a sample for implementation.
http://websamples.syncfusion.com/samples/Grid.Windows/F61668/main.htm

Best regards,
Haneef

Miki Watts
Replied On June 4, 2007 01:14 PM

Thanks Haneef, the OnSetControlText did it.

Only one problem now, if I select the row using the dropdown, it works just fine and I see the bank code instead of the bank name in the grid cell.

However, if I type the bank name into the grid cell,I still see the bank name in the grid, and when moving around with the keyboard arrows, the bank name changes to the bank code and back whenever i pass over the grid cell.

I need the behaviour to be consistent and act like in the first case I described.

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.

;