Cells in ReoGrid can host a cell body โ€” a component that renders custom content and handles user interaction. ReoGrid provides many built-in cell body types for common UI controls.

Namespace

using unvell.ReoGrid.CellTypes;

Available Cell Types

ClassSampleDescription
ButtonCell361General button
CheckBoxCell363Check box (toggles true/false)
RadioButtonCell365Radio button (mutual exclusion within a group)
HyperlinkCell362Hyperlink with optional auto-navigation
DropdownListCell367Drop-down list for single item selection
ComboListCellCombo box with text input and drop-down selection
ProgressCell368Progress bar (value 0โ€“1)
NegativeProgressCell370Positive/negative progress bar
ImageCell369Displays an image
ImageButtonCell389Image on a button
DatePickerCell381Date picker with calendar drop-down
ColumnDropdownListCellDrop-down list using column data as source

Setting a Cell Body

// Via worksheet indexer
sheet[1, 2] = new ButtonCell("Click Me");

// Via cell instance
var cell = sheet.Cells["C3"];
cell.Body = new CheckBoxCell();

ICellBody Interface

All cell bodies implement ICellBody. The CellBody base class provides default implementations:

MemberDescription
OnSetup(Cell cell)Called when the body is attached to a cell
OnPaint(CellDrawingContext dc)Render the cell body
OnMouseDown/Up/Move/Enter/LeaveMouse interaction handlers (return true to consume the event)
OnMouseWheel(e)Mouse wheel handler
OnKeyDown/Up(KeyCode)Keyboard handlers (return true to consume)
OnStartEdit()Called when the cell enters edit mode (return false to prevent)
OnEndEdit(data, reason)Called when edit ends (return modified data or original)
OnSetData(data)Called when cell data is set (return modified data or original)
OnGotFocus() / OnLostFocus()Focus change handlers
AutoCaptureMouse()Whether to capture mouse events (default: true)
DisableWhenCellReadonlyWhether the body is disabled when the cell is read-only (default: true)
CellThe parent cell (read-only, available after OnSetup)
Clone()Create a copy of the cell body

For creating custom cell bodies, see Custom Cell.


ButtonCell

A clickable button that displays the cellโ€™s data as its label.

ButtonCell

// With default text
sheet[1, 2] = new ButtonCell("Hello");

// Without text โ€” uses cell data as label
sheet[1, 2] = new ButtonCell();
sheet[1, 2] = "Hello";

Properties

PropertyTypeDescription
IsPressedboolWhether the button is currently pressed

Events

EventDescription
ClickRaised when the user clicks the button

Methods

MethodDescription
PerformClick()Simulate a button click programmatically
var button = new ButtonCell("Hello");
button.Click += (s, e) => MessageBox.Show("Button clicked");
sheet["C3"] = button;

// Programmatic click
button.PerformClick();

Customize Button Appearance

Change the button label color through the cell style:

var cell = sheet.Cells["C3"];
cell.Style.TextColor = Color.Blue;
cell.Body = new ButtonCell("Hello");

358


CheckBoxCell

A check box that toggles the cellโ€™s data between true and false.

p03

var checkbox = new CheckBoxCell();
sheet["C1"] = new object[] { checkbox, "Auto destroy after 5 minutes." };

Constructors

ConstructorDescription
CheckBoxCell()Creates an unchecked checkbox
CheckBoxCell(bool initChecked)Creates a checkbox with initial check state

Properties

PropertyTypeDescription
IsCheckedboolGet or set the check state

Get and Set Check State

// Set via cell data
sheet[1, 2] = true;   // check
sheet[1, 2] = false;  // uncheck

// Get via cell data
bool isChecked = (sheet["C1"] as bool?) ?? false;

// Get/set via checkbox instance
checkbox.IsChecked = true;
bool state = checkbox.IsChecked;

Events

EventDescription
ClickRaised when the user clicks the checkbox (not on Space key)
CheckChangedRaised when the check state changes (by mouse or keyboard)
checkbox.Click += (s, e) => { /* handle click */ };

checkbox.CheckChanged += (s, e) =>
{
    Console.WriteLine($"Checked: {checkbox.IsChecked}");
};

Since the checkbox updates cell data, CellDataChanged also fires:

sheet.CellDataChanged += (s, e) =>
{
    if (e.Cell.Position == new CellPosition("C1"))
        Console.WriteLine("Checkbox changed: " + e.Cell.Data);
};

Custom Drawing

Override OnContentPaint to customize checkbox appearance:

class MyCheckBox : CheckBoxCell
{
    Image checkedImage, uncheckedImage;

    public MyCheckBox()
    {
        checkedImage = Image.FromFile(@"...");
        uncheckedImage = Image.FromFile(@"...");
    }

    protected override void OnContentPaint(CellDrawingContext dc)
    {
        dc.Graphics.DrawImage(
            this.IsChecked ? checkedImage : uncheckedImage,
            this.ContentBounds);
    }
}

360


RadioButtonCell

A radio button that inherits from CheckBoxCell. Radio buttons within the same group toggle each other.

p04

var radio = new RadioButtonCell();
sheet["C3"] = radio;

RadioButtonGroup

Assign a shared RadioButtonGroup so only one radio button can be selected at a time:

var group = new RadioButtonGroup();

sheet[10, 2] = new object[,] {
    { new RadioButtonCell() { RadioGroup = group }, "Apple" },
    { new RadioButtonCell() { RadioGroup = group }, "Orange" },
    { new RadioButtonCell() { RadioGroup = group }, "Banana" },
};

RadioButtonGroup Members

MemberTypeDescription
RadioButtonsList<RadioButtonCell>All radio buttons in this group
AddRadioButton(cell)MethodManually add a radio button to the group
Contains(cell)MethodCheck if a radio button belongs to this group

Properties

PropertyTypeDescription
RadioGroupRadioButtonGroupThe group this radio button belongs to
IsCheckedboolGet or set the selection state (inherited)

Events

// Click event
radio.Click += (s, e) => { /* handle */ };

// CheckChanged on all radios in a group
group.RadioButtons.ForEach(rb =>
    rb.CheckChanged += (s, e) =>
        Console.WriteLine("Selected: " + sheet[rb.Cell.Row, rb.Cell.Column + 1]));

A drop-down list that lets the user choose from a list of items.

206

Constructors

ConstructorDescription
DropdownListCell()Empty drop-down list
DropdownListCell(params string[] candidates)Drop-down with string items
DropdownListCell(IEnumerable<string> candidates)Drop-down with a collection of strings
DropdownListCell(ReferenceRange refRange)Drop-down using a cell range as the data source
var dropdown = new DropdownListCell(
    "Apple", "Orange", "Banana", "Pear",
    "Pumpkin", "Cherry", "Coconut"
);
sheet["B2"] = dropdown;

Properties

PropertyTypeDescription
SelectedItemobjectThe currently selected item
SelectedIndexintIndex of the selected item

Events

EventDescription
SelectedItemChangedRaised when the selected item changes
dropdown.SelectedItemChanged += (s, e) =>
{
    Console.WriteLine("Selected: " + dropdown.SelectedItem);
};

The selected item is also set as cell data, so CellDataChanged fires too.

Learn more at Drop-down List Cell.


ComboListCell

A combo box that combines a text input field with a drop-down selection list. Supports auto-completion while typing.

Constructors

ConstructorDescription
ComboListCell()Empty combo list
ComboListCell(params string[] candidates)With string items
ComboListCell(IEnumerable<string> candidates)With a collection of strings
ComboListCell(ReferenceRange refRange)Using a cell range as the data source
var combo = new ComboListCell("Apple", "Orange", "Banana");
sheet["B2"] = combo;

Properties

PropertyTypeDescription
SelectedItemobjectThe currently selected item
SelectedIndexintIndex of the selected item
EnableAutoCompletionboolEnable auto-completion while typing (default: true)
AutoCompleteCompareratorFunc<string, string, bool>Custom comparison function for auto-completion
CandidationListSearchProviderFunc<object, IList<string>>Custom search provider for the candidate list

Events

EventDescription
SelectedItemChangedRaised when the selected item changes

DropdownCell is the abstract base class for all drop-down cell types. It can be extended to create custom drop-down controls.

166

Properties

PropertyTypeDefaultDescription
PullDownOnClickboolfalseOpen the drop-down panel on cell click
DropdownButtonSizeRGSize16x16Size of the drop-down button
DropdownButtonAutoHeightbooltrueAuto-adjust button height to match cell
IsDropdownboolfalseWhether the drop-down panel is currently open
DropdownPanelHeightint200Height of the drop-down panel
MinimumDropdownWidthint40Minimum width of the drop-down panel
MaximumDropdownWidthint1200Maximum width of the drop-down panel
DropdownControlControlnullThe control displayed in the drop-down panel
DropdownButtonStyleDropdownCellStyleโ€”Style of the drop-down button

Methods

MethodDescription
PushDown(bool forceCellEdit = true)Open the drop-down panel
PullUp()Close the drop-down panel

Events

EventDescription
DropdownOpenedRaised when the drop-down panel opens
DropdownClosedRaised when the drop-down panel closes

See How to Create a Custom Drop-down Cell for creating custom drop-down controls.


ProgressCell

Displays a horizontal progress bar. The cell value (0โ€“1) determines the fill amount.

sheet["B2"] = new ProgressCell();
sheet["B2"] = 0.7;  // 70% progress

Properties

PropertyTypeDefaultDescription
TopColorSolidColorLightSkyBlueTop gradient color of the progress bar
BottomColorSolidColorSkyBlueBottom gradient color of the progress bar
var progress = new ProgressCell
{
    TopColor = SolidColor.LightGreen,
    BottomColor = SolidColor.Green,
};
sheet["B2"] = progress;
sheet["B2"] = 0.5;

NegativeProgressCell

Displays progress bars for both positive and negative values. Positive values extend right from center; negative values extend left.

370

sheet["B2"] = new NegativeProgressCell();
sheet["B2"] = -0.3;  // 30% negative progress

Properties

PropertyTypeDefaultDescription
PositiveColorSolidColorLightGreenColor for positive values
NegativeColorSolidColorLightCoralColor for negative values
LinearGradientbooltrueApply gradient shading
DisplayCellTextbooltrueShow the cell text value
LimitedInsideCellbooltrueLimit the bar to cell boundaries

HyperlinkCell

A clickable hyperlink. Uses the cell data as the display text and navigation URL.

p02

// Auto-navigate to URL on click
sheet[1, 2] = new HyperlinkCell("http://www.google.com", true);

// Or set URL and display text separately
sheet[1, 2] = new HyperlinkCell("http://www.google.com", false);
sheet[1, 2] = "Google";

Constructors

ConstructorDescription
HyperlinkCell()Hyperlink with auto-navigation enabled
HyperlinkCell(string url)Hyperlink with URL and auto-navigation enabled
HyperlinkCell(string url, bool autoNavigate)Hyperlink with configurable auto-navigation

Properties

PropertyTypeDefaultDescription
LinkURLstringnullThe navigation URL
AutoNavigatebooltrueAutomatically navigate when clicked
LinkColorSolidColorBlueColor of unvisited links
VisitedColorSolidColorPurpleColor of visited links
ActivateColorSolidColorRedColor when the link is pressed

Events

EventDescription
ClickRaised when the link is clicked (after navigation if AutoNavigate is true)
var link = new HyperlinkCell("http://myurl.com", false);
link.Click += (s, e) => { /* custom handler */ };
sheet["A1"] = link;

Methods

MethodDescription
PerformClick()Simulate a click programmatically

ImageCell

Displays an image inside a cell.

p07

var image = Image.FromFile("photo.jpg");
sheet[2, 6] = new ImageCell(image);

Constructors

ConstructorDescription
ImageCell()Empty image cell
ImageCell(Image image)Image cell with the specified image
ImageCell(Image image, ImageCellViewMode viewMode)Image cell with view mode

Properties

PropertyTypeDescription
ImageImageThe image to display
ViewModeImageCellViewModeHow the image is displayed

ImageCellViewMode Enum

ValueDescription
StretchFill to cell boundary (default) โ€” may distort the image
ZoomScale proportionally to fit within cell boundary
ClipKeep original size and clip to cell boundary
var imgCell = new ImageCell(img, ImageCellViewMode.Zoom);
sheet["F6"] = imgCell;

Control image position with cell alignment styles:

var cell = sheet.Cells["F6"];
cell.Style.HAlign = ReoGridHorAlign.Center;
cell.Style.VAlign = ReoGridVerAlign.Middle;

ImageButtonCell

A button that displays an image. Inherits from ButtonCell.

390

sheet["C3"] = new ImageButtonCell(Image.FromFile("Save-32.png"));

Properties

PropertyTypeDescription
ImageImageThe image to display on the button

Inherits Click event and PerformClick() method from ButtonCell.


DatePickerCell

A drop-down cell with a month calendar for date selection. WinForms only.

271

sheet["B2"] = new DatePickerCell();

The selected date is stored as the cellโ€™s data.

Note: DatePickerCell is only available in the WinForms edition. For WPF, see How to Create a Date Picker Cell.


ColumnDropdownListCell

A drop-down list that uses column data as its selection source. WinForms only.

sheet["B2"] = new ColumnDropdownListCell();

Cell Body Size

The size of a cell body is determined by its parent cell, including any padding styles. To make a cell body larger, merge multiple cells:

sheet.MergeRange("B2:D4");
sheet["B2"] = new ButtonCell("Large Button");

Platform Availability

Cell TypeWinFormsWPF
ButtonCellYesYes
CheckBoxCellYesYes
RadioButtonCellYesYes
HyperlinkCellYesYes
ImageCellYesYes
ImageButtonCellYesYes
ProgressCellYesYes
NegativeProgressCellYesYes
DropdownCellYesYes
DropdownListCellYesYes
ComboListCellYesYes
ColumnDropdownListCellYesNo
DatePickerCellYesNo
Custom Cell BodyYesYes

Demo Projects

Examples of built-in cell types are included in the Demo project.

WinForms:

62

WPF:

352

Was this article helpful?