ComboListCell creates an editable combo box cell: users can type freely, rely on auto-completion, or pick from a drop-down list. Unlike DropdownListCell (selection-only), ComboListCell accepts new values typed by the user.
Namespace
using unvell.ReoGrid.CellTypes;
Create a Combo List Cell
var sheet = grid.CurrentWorksheet;
var combo = new ComboListCell("Apple", "Banana", "Orange", "Applause", "Appreciate");
sheet.Cells["C3"].Body = combo;
Constructors
| Constructor | Description |
|---|---|
ComboListCell() | Empty combo list |
ComboListCell(params string[] candidates) | Create with string items |
ComboListCell(List<string> candidates) | Create with a mutable list (stays linked) |
ComboListCell(IEnumerable<string> candidates) | Create with any collection |
ComboListCell(ReferenceRange refRange) | Create using a cell range as the data source |
Using a Mutable List
Pass a List<string> to keep items in sync. New items added to the list appear in the dropdown:
var items = new List<string> { "Alpha", "Beta", "Gamma" };
var combo = new ComboListCell(items);
sheet["B5"] = combo;
items.Add("Delta"); // immediately available in the dropdown
Using a Cell Range
Bind to a range so the list reflects current cell contents:
var combo = new ComboListCell(sheet.Ranges["A2:A20"]);
sheet["D2"] = combo;
Properties
ComboListCell Properties
| Property | Type | Default | Description |
|---|---|---|---|
SelectedItem | object | — | The currently selected item |
SelectedIndex | int | — | Index of the selected item |
EnableAutoCompletion | bool | true | Enable auto-completion while typing |
AutoCompleteComparerator | Func<string, string, bool> | prefix match | Custom comparison function |
CandidationListSearchProvider | Func<object, IList<string>> | null | Custom search provider for large/remote datasets |
Inherited from DropdownCell
| Property | Type | Default | Description |
|---|---|---|---|
PullDownOnClick | bool | false | Open drop-down when cell is clicked |
DropdownButtonSize | RGSize | 16x16 | Size of the drop-down button |
DropdownButtonAutoHeight | bool | true | Auto-adjust button height to match cell |
IsDropdown | bool | — | Whether the drop-down panel is currently open |
DropdownPanelHeight | int | 200 | Height of the drop-down panel |
MinimumDropdownWidth | int | 40 | Minimum width of the drop-down panel |
MaximumDropdownWidth | int | 1200 | Maximum width of the drop-down panel |
DropdownControl | Control | — | The platform control in the panel |
DropdownButtonStyle | DropdownCellStyle | — | Visual style of the drop-down button |
Events
| Event | Description |
|---|---|
SelectedItemChanged | Raised when the selected item changes |
DropdownOpened | Raised when the drop-down panel opens (inherited) |
DropdownClosed | Raised when the drop-down panel closes (inherited) |
combo.SelectedItemChanged += (s, e) =>
{
Console.WriteLine($"Selected: {combo.SelectedItem}");
};
Methods
| Method | Description |
|---|---|
PushDown(bool forceCellEdit = true) | Programmatically open the drop-down panel |
PullUp() | Close the drop-down panel |
Clone() | Create a copy of this cell body |
Auto-Completion
Auto-completion is enabled by default. As the user types, matching items are suggested and the remaining text is auto-filled.
Disable Auto-Completion
combo.EnableAutoCompletion = false;
Custom Comparison Logic
The default comparison uses a case-insensitive prefix match (StartsWith). Override it for different behavior:
// Substring match instead of prefix match
combo.AutoCompleteComparerator = (item, text) =>
{
if (string.IsNullOrWhiteSpace(text)) return false;
return item.Contains(text, StringComparison.OrdinalIgnoreCase);
};
The function signature is Func<string, string, bool> where:
- First parameter: the candidate item text
- Second parameter: the text the user has typed
- Return
trueto include the item in suggestions
Custom Search Provider
For large or remote datasets, supply a search provider that returns filtered candidates dynamically:
combo.CandidationListSearchProvider = text =>
{
return ProductSearch(text?.ToString())
.Take(20)
.ToList();
};
The function signature is Func<object, IList<string>> where:
- Parameter: the text currently typed by the user
- Return: the filtered list of candidates to display
When a search provider is set, it replaces the default filtering behavior entirely.
Capturing New Values
Since ComboListCell allows free text input, users can type values not in the original list. Capture these and add them for future suggestions:
var items = new List<string> { "Alpha", "Beta" };
var combo = new ComboListCell(items);
sheet["B5"] = combo;
sheet.AfterCellEdit += (s, e) =>
{
if (ReferenceEquals(e.Cell.Body, combo) &&
e.NewData is string text &&
!string.IsNullOrWhiteSpace(text) &&
!items.Contains(text))
{
items.Add(text);
}
};
Keyboard Behavior
| Key | Action |
|---|---|
| Up / Down | Navigate through the suggestion list |
| Enter / Space | Confirm the highlighted item |
| Tab | Confirm and move to the next cell |
| Escape | Close the drop-down without selecting |
WPF Styling
On WPF, customize the list appearance through the Style property:
#if WPF
combo.Style.TextColor = SolidColor.DarkBlue;
combo.Style.BackColor = SolidColor.LightYellow;
combo.Style.FontSize = 14;
combo.Style.FontWeight = FontWeights.Bold;
#endif
ComboListStyle Properties (WPF Only)
| Property | Type | Description |
|---|---|---|
TextColor | SolidColor | Text color in the list |
BackColor | SolidColor | Background color |
Font | FontFamily | Font family |
FontWeight | FontWeight | Font weight |
FontSize | double | Font size |
FontStyle | FontStyle | Font style |
HorizontalAlignment | HorizontalAlignment | Item horizontal alignment |
VerticalAlignment | VerticalAlignment | Item vertical alignment |
Padding | PaddingValue | Item padding |
Reset() | method | Reset to default style |
Override the ListBox Template (WPF)
Swap in a custom ControlTemplate/ItemTemplate for the drop-down ListBox:
<Window.Resources>
<ControlTemplate x:Key="ReoGridComboListTemplate" TargetType="ListBox">
<Border Background="#101820" CornerRadius="6" Padding="4">
<ScrollViewer Focusable="False">
<ItemsPresenter />
</ScrollViewer>
</Border>
</ControlTemplate>
<DataTemplate x:Key="ReoGridComboItemTemplate">
<StackPanel Orientation="Horizontal" Margin="4,2">
<Ellipse Width="6" Height="6" Fill="#FF7A00" Margin="0,0,6,0"/>
<TextBlock Text="{Binding}" Foreground="White"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
Wire it up in code:
#if WPF
combo.DropdownOpened += (s, e) =>
{
if (((ComboListCell)s).DropdownControl is ListBox listBox)
{
listBox.Template = (ControlTemplate)FindResource("ReoGridComboListTemplate");
listBox.ItemTemplate = (DataTemplate)FindResource("ReoGridComboItemTemplate");
}
};
#endif
Extending ComboListCell
Subclass ComboListCell for deeper customization:
class ProductComboCell : ComboListCell
{
private readonly ProductService _service;
public ProductComboCell(ProductService service) : base()
{
_service = service;
CandidationListSearchProvider = text =>
_service.Search(text?.ToString()).Select(p => p.Name).ToList();
}
}
Comparison: DropdownListCell vs ComboListCell
| Feature | DropdownListCell | ComboListCell |
|---|---|---|
| Select from list | Yes | Yes |
| Type free text | No | Yes |
| Auto-completion | No | Yes (configurable) |
| Custom search provider | No | Yes |
| Accepts new values | No | Yes |
Class Hierarchy
CellBody
└─ DropdownCell (panel, button, open/close)
└─ DropdownListBaseCell (candidate source)
├─ DropdownListCell (selection-only)
└─ ComboListCell (editable + auto-complete)
Related Topics
- Built-in Cell Types — All cell type overview
- Dropdown List Cell — Selection-only dropdown
- Custom Cell — Creating custom cell bodies
- How to Create Custom Drop-down Cell — Custom drop-down tutorial