Skip to main content Skip to footer

How to Display a Scrollbar in a FlexGrid cell when Editing Large Text

When editing a cell in FlexGrid that has too much text, its possible to add a scrollbar to allow scrolling to see the entire cell.

We can declare the host control, in this case FlexGrid, and then add a scrollbar property to it.

var scrollableColumnIndex = _flex.Cols.IndexOf("Description");

for (int i = 1; i < _flex.Rows.Count; i++)
{
    TextBox tbx = new TextBox() { Multiline = true, ScrollBars = ScrollBars.Vertical };
    tbx.Multiline = true;
    _al.Add(new HostedControl(_flex, tbx, i, scrollableColumnIndex));
}

_flex.Paint += (s, e1) =>
{
    foreach (HostedControl hosted in _al)
        hosted.UpdatePosition();
};