Style

ReoGrid uses an enumeration called 'PlainStyleFlag' to determine what styles should be handled.

Set Styles

Method

Always set style to a range instead of cell.
grid.SetRangeStyle(ReoGridRange range, ReoGridRangeStyle styleSet);

Action

grid.DoAction(new RGSetRangeStyleAction(ReoGridRange range, ReoGridRangeStyle styleSet));

Script

grid.getCell(0, 0).style.backgroundColor = 'red';

Get Styles

Getting styles from range or cell:
grid.GetRangeStyle(ReoGridRange range);
grid.GetCellStyle(ReoGridPos pos);

Background Color

Set background to range (2,1,3,4):
grid.SetRangeStyle(new ReoGridRange(2, 1, 3, 4),
  new Unvell.ReoGrid.ReoGridRangeStyle
  {
    Flag = PlainStyleFlag.FillColor,
    BackColor = Color.SkyBlue,
  });
15_2.png

Background Pattern Color

Set background pattern color to entire grid:
grid.SetRangeStyle(ReoGridRange.EntireRange, 
  new Unvell.ReoGrid.ReoGridRangeStyle {
    Flag = PlainStyleFlag.FillPattern | PlainStyleFlag.FillColor,
    BackColor = Color.LightYellow,
    FillPatternColor = Color.SkyBlue,
    FillPatternStyle = System.Drawing.Drawing2D.HatchStyle.DiagonalBrick
  });
14.png

Text color

Set text color to red:
grid.SetRangeStyle(new ReoGridRange(1, 1, 1, 1), new ReoGridRangeStyle()
{
  Flag = PlainStyleFlag.TextColor,
  TextColor = Color.Red,
});
44.png

Text alignments

Text alignment can be specified by horizontal and vertical directions.
43.png
Set cell's text horizontal alignment to 'Center':
grid.DoAction(new RGSetRangeStyleAction(new ReoGridRange(0, 0, 3, 3),
  new ReoGridRangeStyle
  {
    Flag = PlainStyleFlag.HorizontalAlign,
    HAlign = ReoGridHorAlign.Center,
  }));
16_2.png

Text wrap

Set text wrap mode to 'WordWrap': (default is no-wrap)
grid[1, 1] = "How many beers can you drink?";
grid.SetRangeStyle(new ReoGridRange(1, 1, 1, 1), new ReoGridRangeStyle()
{
  Flag = PlainStyleFlag.TextWrap,
  TextWrapMode = TextWrapMode.WordBreak,
});
45.png

Font

Change font name and size:
grid.SetRangeStyle(new ReoGridRange(1, 1, 1, 1), new ReoGridRangeStyle()
{
  Flag = PlainStyleFlag.FontSize | PlainStyleFlag.FontName,
  FontName = "Arial",
  FontSize = 20,
});
46.png

Remove Style

Always remove style from range even single cell needed.

Method

By specifying PlainStyleFlag flag to decide what styles to be removed.

Remove background color from specified range:
grid.RemoveRangeStyle(new ReoGridRange(2, 2, 3, 3), PlainStyleFlag.FillAll);

Action

Remove background color from specified range:
grid.DoAction(new RGRemoveRangeStyleAction(new ReoGridRange(2, 2, 3, 3), PlainStyleFlag.FillAll));

Next: Clipboard

Last edited Feb 5, 2014 at 2:06 PM by unvell, version 7