public static GridModel LoadSoap(Stream s)
{
try
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(GridWindowsAssembly.AssemblyResolver);
SoapFormatter b = new SoapFormatter();
b.AssemblyFormat = FormatterAssemblyStyle.Simple;
GridModel t = b.Deserialize(s) as GridModel;
t.Modified = false;
return t;
}
finally
{
AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(GridWindowsAssembly.AssemblyResolver);
}
}
void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
{
//Removes border margins from a given cell rectangle.
GridRangeInfo range = this.gridControl1.Model.CoveredRanges.FindRange(e.RowIndex, e.ColIndex);
Rectangle rect = this.gridControl1.RangeInfoToRectangle(range);
this.gridControl1.CurrentCell.Model.SubtractBorders(rect, style, true);
}
Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
'Removes border margins from a given cell rectangle.
Dim range As GridRangeInfo = Me.gridControl1.Model.CoveredRanges.FindRange(e.RowIndex, e.ColIndex)
Dim rect As Rectangle = Me.gridControl1.RangeInfoToRectangle(range)
Me.gridControl1.CurrentCell.Model.SubtractBorders(rect, style, True)
End Sub
void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
{
string text="GridControl";
this.gridControl1.CurrentCell.Model.SetActiveText(e.RowIndex, e.ColIndex, text);
}
Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
Dim text As String="Active Text"
Me.gridControl1.CurrentCell.Model.SetActiveText(e.RowIndex, e.ColIndex, text)
End Sub
//Scroll position based on the column index.
public override object GetEditState()
{
if (this.gridControl1.CurrentCell.IsEditing)
{
return new int[] { 0, this.gridControl1[this.gridControl1.CurrentCell.RowIndex,this.gridControl1.CurrentCell.ColIndex].Text.Length };
}
return null;
}
Public Overrides Function GetEditState() As Object
If Me.gridControl1.CurrentCell.IsEditing Then
Return New Integer(){ 0, Me.gridControl1(Me.gridControl1.CurrentCell.RowIndex, Me.gridControl1.CurrentCell.ColIndex).Text.Length }
End If
Return Nothing
End Function
public static void Draw3dFrame(Graphics g, int x0, int y0, int x1, int y1, int w, Color rgbTopLeft, Color rgbBottomRight)
{
Rectangle rc;
for (int i = 0; i != w; i++)
{
// Top
Brush brTL = new SolidBrush(rgbTopLeft);
rc = Rectangle.FromLTRB(x0, y0, x1, y0+1);
g.FillRectangle(brTL, rc);
// Left
rc = Rectangle.FromLTRB(x0, y0, x0+1, y1);
g.FillRectangle(brTL, rc);
brTL.Dispose();
Brush brBR = new SolidBrush(rgbBottomRight);
// Bottom
rc = Rectangle.FromLTRB(x0, y1, x1+1, y1+1);
g.FillRectangle(brBR, rc);
// Right
rc = Rectangle.FromLTRB(x1, y0, x1+1, y1);
g.FillRectangle(brBR, rc);
brBR.Dispose();
if (i != w-1)
{
x0++;
y0++;
x1--;
y1--;
}
}
}
protected override void OnDrawCellButtonBackground(GridCellButton button, Graphics g, Rectangle rect, ButtonState buttonState, GridStyleInfo style)
{
bool drawPressed = (buttonState & ButtonState.Pushed) != 0;
Color hilight = SystemColors.ControlLightLight;
Color shadow = SystemColors.ControlDarkDark;
if (!drawPressed)
{
GridPaint.Draw3dFrame(g, rect.Left, rect.Top, rect.Right-1, rect.Bottom-1, 1,
hilight, shadow);
}
else
{
Brush br = new SolidBrush(shadow);
g.FillRectangle(br, Rectangle.FromLTRB(rect.Left, rect.Bottom-1, rect.Right-1, rect.Bottom));
g.FillRectangle(br, Rectangle.FromLTRB(rect.Right-1, rect.Top, rect.Right, rect.Bottom));
br.Dispose();
}
}
Public Shared Sub Draw3dFrame(g As Graphics, x0 As Integer, y0 As Integer, x1 As Integer, y1 As Integer, w As Integer, rgbTopLeft As Color, rgbBottomRight As Color)
Dim rc As Rectangle
Dim i As Integer
While i <> w
' Top
Dim brTL = New SolidBrush(rgbTopLeft)
rc = Rectangle.FromLTRB(x0, y0, x1, y0 + 1)
g.FillRectangle(brTL, rc)
' Left
rc = Rectangle.FromLTRB(x0, y0, x0 + 1, y1)
g.FillRectangle(brTL, rc)
brTL.Dispose()
Dim brBR = New SolidBrush(rgbBottomRight)
' Bottom
rc = Rectangle.FromLTRB(x0, y1, x1 + 1, y1 + 1)
g.FillRectangle(brBR, rc)
' Right
rc = Rectangle.FromLTRB(x1, y0, x1 + 1, y1)
g.FillRectangle(brBR, rc)
brBR.Dispose()
If i <> w - 1 Then
x0 += 1
y0 += 1
x1 -= 1
y1 -= 1
End If
i += 1
End While
End Sub 'Draw3dFrame
Protected Overrides Sub OnDrawCellButtonBackground(button As GridCellButton, g As Graphics, rect As Rectangle, buttonState As ButtonState, style As GridStyleInfo)
Dim drawPressed As Boolean = (buttonState And ButtonState.Pushed) <> 0
Dim hilight As Color = SystemColors.ControlLightLight
Dim shadow As Color = SystemColors.ControlDarkDark
If Not drawPressed Then
GridPaint.Draw3dFrame(g, rect.Left, rect.Top, rect.Right - 1, rect.Bottom - 1, 1, hilight, shadow)
Else
Dim br = New SolidBrush(shadow)
g.FillRectangle(br, Rectangle.FromLTRB(rect.Left, rect.Bottom - 1, rect.Right - 1, rect.Bottom))
g.FillRectangle(br, Rectangle.FromLTRB(rect.Right - 1, rect.Top, rect.Right, rect.Bottom))
br.Dispose()
End If
End Sub 'OnDrawCellButtonBackground
public override bool ValidateString(string text)
{
TraceUtil.TraceCurrentMethodInfoIf(Switches.CellRenderer.TraceVerbose, text);
if (text.IndexOf("-") != -1)
return false;
return true;
}
form.Text = "Password Cells";
gridControl1.BeginUpdate();
gridControl1.TableStyle.FloatCell = true;
gridControl1.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation;
gridControl1.TableStyle.BackColor = Color.FromArgb(204, 212, 230);
gridControl1.TableStyle.CellType = "OriginalTextBox";
GridStyleInfo style;
for (int row = 2; row != 10; row++)
{
style = gridControl1[row, 2];
style.PasswordChar = '*';
style.Text = new string((char) (65 + row), row);
style = gridControl1[row, 3];
style.CharacterCasing = CharacterCasing.Lower;
style.Text = new string((char) (65 + row), row);
style = gridControl1[row, 4];
style.CharacterCasing = CharacterCasing.Upper;
style.Text = new string((char) (65 + row), row);
}
gridControl1.EndUpdate(true);
form.Text = "Password Cells"
gridControl1.BeginUpdate()
gridControl1.TableStyle.FloatCell = True
gridControl1.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation
gridControl1.TableStyle.BackColor = Color.FromArgb(204, 212, 230)
gridControl1.TableStyle.CellType = "OriginalTextBox"
Dim style As GridStyleInfo
Dim row As Integer
For row = 2 To 10
style = gridControl1(row, 2)
style.PasswordChar = "*"c
style.Text = New String(ChrW(65 + row), row)
style = gridControl1(row, 3)
style.CharacterCasing = CharacterCasing.Lower
style.Text = New String(ChrW(65 + row), row)
style = gridControl1(row, 4)
style.CharacterCasing = CharacterCasing.Upper
style.Text = New String(ChrW(65 + row), row)
Next row
gridControl1.EndUpdate(True)
//Enable the Office2007ScrollBars.
this.gridControl1.Office2007ScrollBars = true;
//Set the color for office2007ScrollBars.
this.gridControl1.Office2007ScrollBarsColorScheme = Office2007ColorScheme.Black;
'Enable the Office2007ScrollBars.
Me.gridControl1.Office2007ScrollBars = True
'Set the color for office2007ScrollBars.
Me.gridControl1.Office2007ScrollBarsColorScheme = Office2007ColorScheme.Black
//Creates the Graphics for the control.
Graphics graphics = this.gridControl1.CreateGridGraphics();
'Creates the Graphics for the control.
Dim graphics As Graphics = Me.gridControl1.CreateGridGraphics()
void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
{
GridStyleInfo style;
style = this.gridControl1.GetViewStyleInfo(e.RowIndex,e.ColIndex);
}
Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
Dim style As GridStyleInfo
style = Me.gridControl1.GetViewStyleInfo(e.RowIndex,e.ColIndex)
End Sub
bool drawDirectToDC = true;
Graphics g = null;
if (drawDirectToDC)
g = m_syncGrid.CreateGridGraphics();
// Clear our volatile cache
m_syncGrid.ResetVolatileData();
// Handle case when values is change for current cell.
if (g1 == m_syncGrid.CurrentCell.RangeInfo)
{
m_syncGrid.CurrentCell.Model.ResetActiveText(row, col);
continue;
}
// Draw direct to dc
if (drawDirectToDC)
{
Rectangle bounds = m_syncGrid.RangeInfoToRectangle(g1);
if (!bounds.IsEmpty)
{
// Instead of
if (false)
{
// Draw each cell individually to graphics context
GridStyleInfo style = this.m_syncGrid.Model[row, col];
GridCellRendererBase renderer = this.m_syncGrid.CellRenderers[style.CellType];
// Get client rectangle
bounds = style.CellModel.SubtractBorders(bounds, style, this.m_syncGrid.IsRightToLeft());
// Draw cell Background
Syncfusion.Drawing.BrushPaint.FillRectangle(g, bounds, style.Interior);
// Draw cell text
renderer.Draw(g, bounds, row, col, style);
}
else
{
// DrawClippedGrid method lets you simply draw the cells at the specified bounds directly to the graphics context.
// less code than drawing each cell individually ....
m_syncGrid.DrawClippedGrid(g, bounds);
}
}
else
{
// Use more conventional Invalidate / Update mechanism.
m_syncGrid.RefreshRange(GridRangeInfo.Cell(row, col);
}
if (g != null)
g.Dispose();
public Form1()
{
InitializeComponent();
this.gridDataBoundGrid2.CurrentCellInitializeControlText += new GridCurrentCellInitializeControlTextEventHandler(gridDataBoundGrid2_CurrentCellInitializeControlText);
this.sqlDataAdapter1.Fill(this.dataSet11);
}
void gridDataBoundGrid2_CurrentCellInitializeControlText(object sender, GridCurrentCellInitializeControlTextEventArgs e)
{
if (e.CellValue != null)
{
e.ControlText = e.CellValue.ToString();
}
}
public Form1()
{
InitializeComponent();
this.gridDataBoundGrid2.CurrentCellErrorMessage += new GridCurrentCellErrorMessageEventHandler(gridDataBoundGrid2_CurrentCellErrorMessage);
this.sqlDataAdapter1.Fill(this.dataSet11);
}
void gridDataBoundGrid2_CurrentCellErrorMessage(object sender, GridCurrentCellErrorMessageEventArgs e)
{
MessageBox.Show(e.Owner, e.Text);
e.Cancel = true;
}
public override void OnCurrentCellValidateString(GridCurrentCellValidateStringEventArgs e)
{
TraceUtil.TraceCurrentMethodInfoIf(Switches.CellRenderer.TraceVerbose, e);
if (e.Text.IndexOf("-") != -1)
e.Cancel = true;
base.OnCurrentCellValidateString(e);
}
/// Current cell will be moving from one position to another.
protected override void OnCurrentCellMoving(GridCurrentCellMovingEventArgs e)
{
e.Options |= GridSetCurrentCellOptions.BeginEndUpdate;
// Instead of GridSetCurrentCellOptions.BeginEndUpdate we could also
// sandwich the call in a Begin/EndUpdate pair ourselves ...
//BeginUpdate(BeginUpdateOptions.InvalidateAndScroll);
}
/// Completes a current cell's MoveTo operation indicating success.
protected override void OnCurrentCellMoved(GridCurrentCellMovedEventArgs e)
{
base.OnCurrentCellMoved(e);
//EndUpdate();
}
/// Completes a current cell's MoveTo operation indicating failure.
protected override void OnCurrentCellMoveFailed(GridCurrentCellMoveFailedEventArgs e)
{
base.OnCurrentCellMoveFailed(e);
//EndUpdate();
}
/// Highlight the current row.
protected override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > this.Model.Rows.HeaderCount && e.ColIndex > this.Model.Cols.HeaderCount
&& CurrentCell.HasCurrentCellAt(e.RowIndex))
{
e.Style.Interior = new BrushInfo(SystemColors.Highlight);
e.Style.TextColor = SystemColors.HighlightText;
e.Style.Font.Bold = true;
}
base.OnPrepareViewStyleInfo(e);
}
/// Refresh the whole row for the old position of the current cell when it is moved to
/// a new row or when current cell is deactivated stand-alone.
protected override void OnCurrentCellDeactivated(GridCurrentCellDeactivatedEventArgs e)
{
// Check if Deactivate is called stand-alone or called from MoveTo and row is moving.
if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex)
{
RefreshRange(GridRangeInfo.Row(e.RowIndex), GridRangeOptions.MergeAllSpannedCells);
}
base.OnCurrentCellDeactivated(e);
}
/// Refresh the whole row for the new current cell position when the current cell is moved
/// to a new row or when current cell is activated stand-alone (and there was no activated current cell).
protected override void OnCurrentCellActivated(EventArgs e)
{
// Check if Activate is called stand-alone or called from MoveTo and row is moving
base.OnCurrentCellActivated(e);
if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex
|| !CurrentCell.MoveFromActiveState)
{
RefreshRange(GridRangeInfo.Row(CurrentCell.RowIndex), GridRangeOptions.MergeAllSpannedCells);
}
}
GridStyleInfo style = Model[rowIndex, colIndex];
GridCellRendererBase renderer = CellRenderers[style.CellType];
gridTableControl.UpdateWithCustomPaint(bounds, new PaintEventHandler(TableControl_CustomPaint));
void TableControl_CustomPaint(object sender, PaintEventArgs e)
{
Rectangle clipBounds = Rectangle.Truncate(e.Graphics.ClipBounds);
gridTableControl.DrawClippedGrid(e.Graphics, clipBounds, false);
}
GridControlBase grid;
int min = grid.GetMinimumTopRowIndex();
int max = grid.GetMaximumTopRowIndex();
for (int v = min; v <= max; v++)
{
grid.TopRowIndex = v;
}
Dim grid As GridControlBase
int min = grid.GetMinimumTopRowIndex();
int max = grid.GetMaximumTopRowIndex();
for (int v = min; v <= max; v++)
{
grid.TopRowIndex = v;
}
GridControlBase grid;
int min = grid.GetMinimumTopRowIndex();
int max = grid.GetMaximumTopRowIndex();
for (int v = min; v <= max; v++)
{
grid.TopRowIndex = v;
}
Dim grid As GridControlBase
int min = grid.GetMinimumTopRowIndex();
int max = grid.GetMaximumTopRowIndex();
for (int v = min; v <= max; v++)
{
grid.TopRowIndex = v;
}
GridControlBase grid;
int min = grid.GetMinimumLeftColIndex();
int max = grid.GetMaximumLeftColIndex();
for (int v = min; v <= max; v++)
{
grid.LeftColIndex = v;
}
Dim grid As GridControlBase
int min = grid.GetMinimumLeftColIndex();
int max = grid.GetMaximumLeftColIndex();
for (int v = min; v <= max; v++)
{
grid.LeftColIndex = v;
}
GridControlBase grid;
int min = grid.GetMinimumLeftColIndex();
int max = grid.GetMaximumLeftColIndex();
for (int v = min; v <= max; v++)
{
grid.LeftColIndex = v;
}
Dim grid As GridControlBase
int min = grid.GetMinimumLeftColIndex();
int max = grid.GetMaximumLeftColIndex();
for (int v = min; v <= max; v++)
{
grid.LeftColIndex = v;
}
public static void Draw3dFrame(Graphics g, int x0, int y0, int x1, int y1, int w, Color rgbTopLeft, Color rgbBottomRight)
{
Rectangle rc;
for (int i = 0; i != w; i++)
{
// Top
Brush brTL = new SolidBrush(rgbTopLeft);
rc = Rectangle.FromLTRB(x0, y0, x1, y0+1);
g.FillRectangle(brTL, rc);
// Left
rc = Rectangle.FromLTRB(x0, y0, x0+1, y1);
g.FillRectangle(brTL, rc);
brTL.Dispose();
Brush brBR = new SolidBrush(rgbBottomRight);
// Bottom
rc = Rectangle.FromLTRB(x0, y1, x1+1, y1+1);
g.FillRectangle(brBR, rc);
// Right
rc = Rectangle.FromLTRB(x1, y0, x1+1, y1);
g.FillRectangle(brBR, rc);
brBR.Dispose();
if (i != w-1)
{
x0++;
y0++;
x1--;
y1--;
}
}
}
protected override void OnDrawCellButtonBackground(GridDrawCellButtonBackgroundEventArgs e)
{
bool drawPressed = (e.ButtonState & ButtonState.Pushed) != 0;
Rectangle rect = e.Bounds;
Graphics g = e.Graphics;
Color hilight = SystemColors.ControlLightLight;
Color shadow = SystemColors.ControlDarkDark;
if (!drawPressed)
{
Draw3dFrame(e.Graphics, rect.Left, rect.Top, rect.Right-1, rect.Bottom-1, 1,
hilight, shadow);
}
else
{
Brush br = new SolidBrush(shadow);
g.FillRectangle(br, Rectangle.FromLTRB(rect.Left, rect.Bottom-1, rect.Right-1, rect.Bottom));
g.FillRectangle(br, Rectangle.FromLTRB(rect.Right-1, rect.Top, rect.Right, rect.Bottom));
br.Dispose();
}
e.Cancel = true;
}
/// Current cell will be moving from one position to another.
protected override void OnCurrentCellMoving(GridCurrentCellMovingEventArgs e)
{
e.Options |= GridSetCurrentCellOptions.BeginEndUpdate;
}
/// Highlight the current row.
protected override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > this.Model.Rows.HeaderCount && e.ColIndex > this.Model.Cols.HeaderCount
&& CurrentCell.HasCurrentCellAt(e.RowIndex))
{
e.Style.Interior = new BrushInfo(SystemColors.Highlight);
e.Style.TextColor = SystemColors.HighlightText;
e.Style.Font.Bold = true;
}
base.OnPrepareViewStyleInfo(e);
}
/// Refresh the whole row for the old position of the current cell when it is moved to
/// a new row or when current cell is deactivated stand-alone.
protected override void OnCurrentCellDeactivated(GridCurrentCellDeactivatedEventArgs e)
{
// Check if Deactivate is called stand-alone or called from MoveTo and row is moving
if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex)
{
RefreshRange(GridRangeInfo.Row(e.RowIndex), GridRangeOptions.MergeAllSpannedCells);
}
base.OnCurrentCellDeactivated(e);
}
/// Refresh the whole row for the new current cell position when the current cell is moved
/// to a new row or when current cell is activated stand-alone (and there was no activated current cell).
protected override void OnCurrentCellActivated(EventArgs e)
{
// Check if Activate is called stand-alone or called from MoveTo and row is moving
base.OnCurrentCellActivated(e);
if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex
|| !CurrentCell.MoveFromActiveState)
{
RefreshRange(GridRangeInfo.Row(CurrentCell.RowIndex), GridRangeOptions.MergeAllSpannedCells);
}
}
/// Current cell will be moving from one position to another.
protected override void OnCurrentCellMoving(GridCurrentCellMovingEventArgs e)
{
e.Options |= GridSetCurrentCellOptions.BeginEndUpdate;
// Instead of GridSetCurrentCellOptions.BeginEndUpdate we could also
// sandwich the call in a Begin/EndUpdate pair ourselves ...
//BeginUpdate(BeginUpdateOptions.InvalidateAndScroll);
}
/// Completes a current cell's MoveTo operation indicating success.
protected override void OnCurrentCellMoved(GridCurrentCellMovedEventArgs e)
{
base.OnCurrentCellMoved(e);
//EndUpdate();
}
/// Completes a current cell's MoveTo operation indicating failure.
protected override void OnCurrentCellMoveFailed(GridCurrentCellMoveFailedEventArgs e)
{
base.OnCurrentCellMoveFailed(e);
//EndUpdate();
}
/// Highlight the current row.
protected override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > this.Model.Rows.HeaderCount && e.ColIndex > this.Model.Cols.HeaderCount
&& CurrentCell.HasCurrentCellAt(e.RowIndex))
{
e.Style.Interior = new BrushInfo(SystemColors.Highlight);
e.Style.TextColor = SystemColors.HighlightText;
e.Style.Font.Bold = true;
}
base.OnPrepareViewStyleInfo(e);
}
/// Refresh the whole row for the old position of the current cell when it is moved to
/// a new row or when current cell is deactivated stand-alone.
protected override void OnCurrentCellDeactivated(GridCurrentCellDeactivatedEventArgs e)
{
// Check if Deactivate is called stand-alone or called from MoveTo and row is moving.
if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex)
{
RefreshRange(GridRangeInfo.Row(e.RowIndex), GridRangeOptions.MergeAllSpannedCells);
}
base.OnCurrentCellDeactivated(e);
}
/// Refresh the whole row for the new current cell position when the current cell is moved
/// to a new row or when current cell is activated stand-alone (and there was no activate current cell).
protected override void OnCurrentCellActivated(EventArgs e)
{
// Check if Activate is called stand-alone or called from MoveTo and row is moving
base.OnCurrentCellActivated(e);
if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex
|| !CurrentCell.MoveFromActiveState)
{
RefreshRange(GridRangeInfo.Row(CurrentCell.RowIndex), GridRangeOptions.MergeAllSpannedCells);
}
}
//Adjust the row and column index if it is covered cell.
int row = this.gridControl1.CurrentCell.RowIndex;
int col = this.gridControl1.CurrentCell.ColIndex;
this.gridControl1.CurrentCell.AdjustRowColIfCoveredCell(ref row, ref col);
'Adjust the row and column if it is covered cell.
Dim row As Integer = Me.gridControl1.CurrentCell.RowIndex
Dim col As Integer = Me.gridControl1.CurrentCell.ColIndex
Me.gridControl1.CurrentCell.AdjustRowColIfCoveredCell(row, col)
this.gridControl1.ViewLayout.Lock();
GridRangeInfo cell = GridRangeInfo.Cell(row, col);
Rectangle bounds = gridControl1.RangeInfoToRectangle(cell);
this.gridControl1.Invalidate(bounds);
this.gridControl1.Update();
this.gridControl1.ViewLayout.Unlock();
GridRangeInfo range;
int topRow,leftCol,bottomRow,rightCol;
//Get the range of cell.
this.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, out range);
//Get the bounds of the cell.
Rectangle rectangle = this.gridControl1.ViewLayout.RangeInfoToRectangle(range);
this.gridControl1.ViewLayout.RectangleToClientRowCol(rectangle,out topRow,out leftCol,out bottomRow,out rightCol,GridCellSizeKind.ActualSize);
Dim range As GridRangeInfo
Dim topRow, leftCol, bottomRow, rightCol As Integer
'Get the range of cell.
Me.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, range)
'Get the bounds of the cell.
Dim rectangle As Rectangle = Me.gridControl1.ViewLayout.RangeInfoToRectangle(range)
Me.gridControl1.ViewLayout.RectangleToClientRowCol(rectangle,topRow,leftCol,bottomRow,rightCol,GridCellSizeKind.ActualSize)
GridRangeInfo range;
int topRow,leftCol,bottomRow,rightCol;
//Get the range of cell.
this.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, out range);
//Get the bounds of the cell.
Rectangle rectangle = this.gridControl1.ViewLayout.RangeInfoToRectangle(range);
this.gridControl1.ViewLayout.RectangleToClientRowCol(rectangle,out topRow,out leftCol,out bottomRow,out rightCol,GridCellSizeKind.ActualSize);
Dim range As GridRangeInfo
Dim topRow, leftCol, bottomRow, rightCol As Integer
'Get the range of cell.
Me.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, range)
'Get the bounds of the cell.
Dim rectangle As Rectangle = Me.gridControl1.ViewLayout.RangeInfoToRectangle(range)
Me.gridControl1.ViewLayout.RectangleToClientRowCol(rectangle,topRow,leftCol,bottomRow,rightCol,GridCellSizeKind.ActualSize)
GridControl gridControl1;
int visibleClientCol = this.gridControl1.ViewLayout.ColIndexToVisibleClient(5);
Console.WriteLine("Visible client column index:" + visibleClientCol);
Dim gridControl1 As GridControl
Dim visibleClientCol As Integer = Me.gridControl1.ViewLayout.ColIndexToVisibleClient(5)
Point point = this.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex,GridCellSizeKind.ActualSize);
Console.Write("Location:" + point);
Dim point As Point = Me.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex,GridCellSizeKind.ActualSize)
Point point = this.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex);
Console.Write("Location:" + point);
Dim point As Point = Me.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex)
GridControl gridControl1;
Point point = this.gridControl1.ViewLayout.ClientRowColToPoint(5, 7,GridCellSizeKind.VisibleSize);
Console.WriteLine("Point:" + point);
Dim gridControl1 As GridControl
Dim point As Point = Me.gridControl1.ViewLayout.ClientRowColToPoint(5, 7,GridCellSizeKind.VisibleSize)
GridControl gridControl1;
Point point = this.gridControl1.ViewLayout.ClientRowColToPoint(5, 7);
Console.WriteLine("Point:" + point);
Dim gridControl1 As GridControl
Dim point As Point = Me.gridControl1.ViewLayout.ClientRowColToPoint(5, 7)
//set ignoreOutsideClientRectangle to True, if the grid should only return points within the grid area
Point point = this.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex,true,GridCellSizeKind.ActualSize);
Console.Write("Location:" + point);
'set ignoreOutsideClientRectangle to True, if the grid should only return points within the grid area
Dim point As Point = Me.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex,True,GridCellSizeKind.ActualSize)
//set ignoreOutsideClientRectangle to True, if the grid should only return points within the grid area
Point point = this.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex,true);
Console.Write("Location:" + point);
'set ignoreOutsideClientRectangle to True, if the grid should only return points within the grid area
Dim point As Point = Me.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex,True)
GridRangeInfo range;
//Get the range of cells.
this.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, out range);
Rectangle rectangle = this.gridControl1.ViewLayout.RangeInfoToRectangle(rangeGridCellSizeKind.ActualSize);
Dim range As GridRangeInfo
'Get the range of cells.
Me.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, range)
Dim rectangle As Rectangle = Me.gridControl1.ViewLayout.RangeInfoToRectangle(range,GridCellSizeKind.ActualSize)
GridRangeInfo range;
//Get the range of cells.
this.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, out range);
Rectangle rectangle = this.gridControl1.ViewLayout.RangeInfoToRectangle(range);
Dim range As GridRangeInfo
'Get the range of cells.
Me.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, range)
Dim rectangle As Rectangle = Me.gridControl1.ViewLayout.RangeInfoToRectangle(range)
GridControl gridControl1;
int colIndex = this.gridControl1.CurrentCell.ColIndex;
int colWidth = this.gridControl1.ViewLayout.GetClientColWidth(colIndexGridCellSizeKind.ActualSize);
Console.WriteLine("ColumnWidth:" + colWidth);
Dim gridControl1 As GridControl
Dim colIndex As Integer = Me.gridControl1.CurrentCell.ColIndex
Dim colWidth As Integer = Me.gridControl1.ViewLayout.GetClientColWidth(colIndex,GridCellSizeKind.ActualSize)
.
GridControl gridControl1;
int colIndex = this.gridControl1.CurrentCell.ColIndex;
int colWidth = this.gridControl1.ViewLayout.GetClientColWidth(colIndex);
Console.WriteLine("ColumnWidth:" + colWidth);
Dim gridControl1 As GridControl
Dim colIndex As Integer = Me.gridControl1.CurrentCell.ColIndex
Dim colWidth As Integer = Me.gridControl1.ViewLayout.GetClientColWidth(colIndex)
GridControl gridControl1;
int rowIndex = this.gridControl1.CurrentCell.RowIndex;
int rowHeight = this.gridControl1.ViewLayout.GetRowHeight(rowIndex,GridCellSizeKind.VisibleSize);
Console.WriteLine("RowHeight:" + rowHeight);
Dim gridControl1 As GridControl
Dim rowIndex As Integer = Me.gridControl1.CurrentCell.RowIndex
Dim rowHeight As Integer = Me.gridControl1.ViewLayout.GetRowHeight(rowIndex,GridCellSizeKind.VisibleSize)
GridControl gridControl1;
int rowIndex = this.gridControl1.CurrentCell.RowIndex;
int rowHeight = this.gridControl1.ViewLayout.GetRowHeight(rowIndex);
Console.WriteLine("RowHeight:" + rowHeight);
Dim gridControl1 As GridControl
Dim rowIndex As Integer = Me.gridControl1.CurrentCell.RowIndex
Dim rowHeight As Integer = Me.gridControl1.ViewLayout.GetRowHeight(rowIndex)
GridRangeInfo range;
//Get the range of cells.
this.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, out range);
//True if the grid should only return points within the grid area.
Rectangle rectangle = this.gridControl1.ViewLayout.RangeInfoToRectangle(range,true,GridCellSizeKind.ActualSize);
Dim range As GridRangeInfo
'Get the range of cells.
Me.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, range)
'True if the grid should only return points within the grid area.
Dim rectangle As Rectangle = Me.gridControl1.ViewLayout.RangeInfoToRectangle(range,True,GridCellSizeKind.ActualSize)
GridRangeInfo range;
//Get the range of cells.
this.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, out range);
//True if the grid should only return points within the grid area.
Rectangle rectangle = this.gridControl1.ViewLayout.RangeInfoToRectangle(range,true);
Dim range As GridRangeInfo
'Get the range of cells.
Me.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, range)
'True if the grid should only return points within the grid area.
Dim rectangle As Rectangle = Me.gridControl1.ViewLayout.RangeInfoToRectangle(range,True)
GridControl gridControl1;
int[] rowHeight = this.gridControl1.ViewLayout.GetRowHeights(4, 6, GridCellSizeKind.ActualSize);
Console.WriteLine("RowHeights:" + rowHeight[i]);
Dim gridControl1 As GridControl
Dim rowHeight() As Integer = Me.gridControl1.ViewLayout.GetRowHeights(4, 6, GridCellSizeKind.ActualSize)
For i As Integer = 0 To 2
Next i
GridControl gridControl1;
int[] rowHeight = this.gridControl1.ViewLayout.GetRowHeights(4, 6);
Console.WriteLine("RowHeights:" + rowHeight[i]);
Dim gridControl1 As GridControl
Dim rowHeight() As Integer = Me.gridControl1.ViewLayout.GetRowHeights(4, 6)
For i As Integer = 0 To 2
Next i
GridControl gridControl1;
int rowHeight = this.gridControl1.ViewLayout.GetRowRangeHeight(4, 6, GridCellSizeKind.VisibleSize);
Console.WriteLine("RowHeights:" + rowHeight);
Dim gridControl1 As GridControl
Dim rowHeight As Integer = Me.gridControl1.ViewLayout.GetRowRangeHeight(4, 6, GridCellSizeKind.VisibleSize)
GridControl gridControl1;
int rowHeight = this.gridControl1.ViewLayout.GetRowRangeHeight(4, 6);
Console.WriteLine("RowHeights:" + rowHeight);
Dim gridControl1 As GridControl
Dim rowHeight As Integer = Me.gridControl1.ViewLayout.GetRowRangeHeight(4, 6)
GridControl gridControl1;
int rangeWidth = this.gridControl1.ViewLayout.GetClientColRangeWidth(4, 6);
Console.WriteLine("RangeWidth:" + rangeWidth);
Dim gridControl1 As GridControl
Dim rangeWidth1 As Integer = Me.gridControl1.ViewLayout.GetClientColRangeWidth(4, 6)
GridControl gridControl1;
this.gridControl1.Model.CoveredRanges.Add(GridRangeInfo.Cells(4, 2, 5, 3));
void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
{
GridRangeInfo range;
if (this.gridControl1.Model.CoveredRanges.Find(e.RowIndex, e.ColIndex, out range))
{
int rangeWidth = this.gridControl1.ViewLayout.GetClientColRangeWidth(range.Left, range.Right, GridCellSizeKind.ActualSize);
Console.WriteLine("RangeWidth:" + rangeWidth);
}
}
Private gridControl1 As GridControl
Me.gridControl1.Model.CoveredRanges.Add(GridRangeInfo.Cells(4, 2, 5, 3))
void gridControl1_CellClick(Object sender, GridCellClickEventArgs e)
Dim range As GridRangeInfo
If Me.gridControl1.Model.CoveredRanges.Find(e.RowIndex, e.ColIndex, range) Then
Dim rangeWidth As Integer = Me.gridControl1.ViewLayout.GetClientColRangeWidth(range.Left, range.Right, GridCellSizeKind.ActualSize)
End If
GridCellModelBase cellModel = grid.Model.CellModels[key];
GridCellRendererBase renderer = cellModel.CreateRenderer(grid);
//Getting the enumerator.
GridCellInfoCollection.GridCellInfoEnumerator cells = this.gridControl1.GridCells.GetEnumerator();
'Getting the enumerator.
Dim cells As GridCellInfoCollection.GridCellInfoEnumerator= Me.gridControl1.GridCells.GetEnumerator()
this.gridControl1.Model.Data.SortByColumn(2);
Me.gridControl1.Model.Data.SortByColumn(2)
this.gridControl1.Model.Data.SortByColumn(2,ListSortDirection.Descending);
Me.gridControl1.Model.Data.SortByColumn(2,ListSortDirection.Descending)
This is a memory efficient way to represent a table where values can remain empty. Only rows
that actually contain data will allocate a
When you access data that are out of range, an empty () object will be returned. If you set data that are out of range, an exception will be thrown. If you set data for a row that was empty, the row will be allocated before the value is stored.
GridRowCollection provides methods that let you insert, remove, or rearrange columns or rows in the table.
Syncfusion.Windows.Forms.DelayedStatusDialog handler = new Syncfusion.Windows.Forms.DelayedStatusDialog();
handler.Delay = 1000;
handler.ShowDialogPercentRule = 25; //default
handler.ShowMousePercentRule = 75; //default values
this.gridControl1.Model.OperationFeedbackListener = handler;
void InitializeComponent()
{
// initialize code
// ...
this.gridControl1.SaveCellText += new Syncfusion.Windows.Forms.Grid.GridCellTextEventHandler(this.gridControl1_SaveCellText);
this.gridControl1.QueryCellFormattedText += new Syncfusion.Windows.Forms.Grid.GridCellTextEventHandler(this.gridControl1_QueryCellFormattedText);
this.gridControl1.SaveCellFormattedText += new Syncfusion.Windows.Forms.Grid.GridCellTextEventHandler(this.gridControl1_SaveCellFormattedText);
this.gridControl1.QueryCellText += new Syncfusion.Windows.Forms.Grid.GridCellTextEventHandler(this.gridControl1_QueryCellText);
}
private void gridControl1_QueryCellFormattedText(object sender, Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs e)
{
}
private void gridControl1_QueryCellText(object sender, Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs e)
{
}
private void gridControl1_SaveCellText(object sender, Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs e)
{
ParseText(e);
}
private void gridControl1_SaveCellFormattedText(object sender, GridCellTextEventArgs e)
{
ParseText(e);
}
void ParseText(GridCellTextEventArgs e)
{
// By default, the grid will display a warning message box informing the user
// the entered value is not valid and the user will have to change the value.
//
// In this event handler, we change the grid default's behavior such that
// when the user enters a value that does not fit the cell's CellValueType,
// the input text is accepted and no warning message is shown.
if (e.Handled)
return;
System.Globalization.CultureInfo ci = e.Style.CultureInfo;
System.Globalization.NumberFormatInfo nfi = ci != null ? ci.NumberFormat : null;
try
{
e.Style.CellValue = GridCellValueConvert.Parse(e.Text, e.Style.CellValueType, nfi, e.Style.Format);
}
catch (Exception ex)
{
if (ex is FormatException || ex.InnerException is FormatException)
{
e.Style.CellValue = e.Text;
// possibly could also change CellValueType here
e.Style.CellValueType = typeof(string);
// - or -
// you could also further analyze the input text and assign a type
// that fits the input text, e.g.
// e.Style.CellValueType = typeof(datetime);
// - or -
// e.Style.CellValueType = typeof(decimal);
// etc.
}
else
throw;
}
e.Handled = true;
}
Private Sub InitializeComponent()
' Initalize code
' ...
AddHandler Me.gridControl1.SaveCellText, AddressOf Me.gridControl1_SaveCellText
AddHandler Me.gridControl1.QueryCellFormattedText, AddressOf Me.gridControl1_QueryCellFormattedText
AddHandler Me.gridControl1.SaveCellFormattedText, AddressOf Me.gridControl1_SaveCellFormattedText
AddHandler Me.gridControl1.QueryCellText, AddressOf Me.gridControl1_QueryCellText
End Sub 'InitializeComponent
Private Sub gridControl1_QueryCellFormattedText(sender As Object, e As Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs)
End Sub 'gridControl1_QueryCellFormattedText
Private Sub gridControl1_QueryCellText(sender As Object, e As Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs)
End Sub 'gridControl1_QueryCellText
Private Sub gridControl1_SaveCellText(sender As Object, e As Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs)
ParseText(e)
End Sub 'gridControl1_SaveCellText
Private Sub gridControl1_SaveCellFormattedText(sender As Object, e As GridCellTextEventArgs)
ParseText(e)
End Sub 'gridControl1_SaveCellFormattedText
Sub ParseText(e As GridCellTextEventArgs)
' By default, the grid will display a warning message box informing the user
' the entered value is not valid and the user will have to change the value.
'
' In this event handler we change the grid default's behavior such that
' when the user enters a value that does not fit the cell's CellValueType,
' the input text is accepted and no warning message is shown.
If e.Handled Then
Return
End If
Dim ci As System.Globalization.CultureInfo = e.Style.CultureInfo
Dim nfi As System.Globalization.NumberFormatInfo = Nothing
If (Not (ci Is Nothing)) Then nfi = ci.NumberFormat
Try
e.Style.CellValue = GridCellValueConvert.Parse(e.Text, e.Style.CellValueType, nfi, e.Style.Format)
Catch ex As Exception
If TypeOf ex Is FormatException OrElse TypeOf ex.InnerException Is FormatException Then
e.Style.CellValue = e.Text
' possibly could also change CellValueType here
' e.Style.CellValueType = typeof(string);
' - or -
' you could also further analyze the input text and assign a type
' that fits the input text, e.g.
' e.Style.CellValueType = typeof(datetime);
' - or -
' e.Style.CellValueType = typeof(decimal);
' etc.
Else
Throw
End If
End Try
e.Handled = True
End Sub 'ParseText
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
IGraphicsProvider graphicsProvider = this.GetGraphicsProvider(); // It is important to hold onto this object as long ad Graphics context is needed!
Graphics g = graphicsProvider.Graphics; // Do not dispose this object! It is a cached Display Device context.
// If nested method calls do call GetGraphicsProvider and get a graphics context the
// same cached graphics context can be returned.
Dim graphicsProvider as IGraphicsProvider = this.GetGraphicsProvider() ' It is important to hold onto this object as long ad Graphics context is needed!
Dim g as Graphics = graphicsProvider.Graphics ' Do not dispose this object! It is a cached Display Device context.
' If nested method calls do call GetGraphicsProvider and get a graphics context the
' same cached graphics context can be returned.
// Cell value for all the grid cells will be changed as "Sample"
this.gridControl1.Model.BaseStylesMap["Standard"].StyleInfo.CellValue = "Sample";
// Backcolor for all the header cells (Row and Column) will be changed as "Red"
this.gridControl1.Model.BaseStylesMap["Header"].StyleInfo.BackColor = Color.Red;
' Cell value for all the grid cells will be changed as "Sample"
Me.gridControl1.Model.BaseStylesMap("Standard").StyleInfo.CellValue = "Sample"
' Backcolor for all the header cells (Row and Column) will be changed as "Red"
Me.gridControl1.Model.BaseStylesMap("Header").StyleInfo.BackColor = Color.Red
// Hiding the first row.
this.gridControl1.Model.HideRows[1] = true;
// Removing the first row from hidden.
this.gridControl1.Model.HideRows [3] = false;
' Hiding the first row.
Me.gridControl1.Model.HideRows(1) = True
' Removing the first row from hidden.
Me.gridControl1.Model.HideRows (3) = False
// Hiding the first column.
this.gridControl1.Model.HideCols[1] = true;
// Removing the second column from hidden.
this.gridControl1.Model.HideCols[4] = false;
' Hiding the first column.
Me.gridControl1.Model.HideCols(1) = True
' Removing the second column from hidden.
Me.gridControl1.Model.HideCols(4) = False
// Undo the actions in the grid.
this.gridControl1.Model.CommandStack.Undo();
//Redo the actions in the grid.
this.gridControl1.Model.CommandStack.Redo();
// Getting the current command mode of the grid.
GridCommandMode commandMode = this.gridControl1.Model.CommandStack.Mode;
' Undo the actions in the grid.
Me.gridControl1.Model.CommandStack.Undo()
'Redo the actions in the grid.
Me.gridControl1.Model.CommandStack.Redo()
' Getting the current command mode of the grid.
Dim commandMode As GridCommandMode = Me.gridControl1.Model.CommandStack.Mode
model[2, 2].Text = "Grid Demo";
model[2, 2].Font.Bold = true;
model[2, 2].Font.Size = 16;
model[2, 2].HorizontalAlignment = GridHorizontalAlignment.Center;
model[2, 2].VerticalAlignment = GridVerticalAlignment.Middle;
model[2, 2].CellType = "Static";
model[2, 2].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(100, 238, 122, 3));
model[2, 2].Interior = new BrushInfo(GradientStyle.PathEllipse, Color.FromArgb(100, 57, 73, 122), Color.FromArgb(237, 240, 247));
If you query for specific attributes in a cell and these attributes have not been explicitly set for the cell,
the
GridStyleInfo standard = model.BaseStylesMap["Standard"].StyleInfo;
standard.TextColor = Color.FromArgb(0, 21, 84);
Color color = model[1, 1].TextColor;
// model[1, 1].TextColor will return Color.FromArgb(0, 21, 84));
// Populating DataSource
DataTable dataTable = new DataTable("Sample");
dataTable.Columns.Add("Column 1");
dataTable.Columns.Add("Column 2");
dataTable.Columns.Add("Column 3");
dataTable.Columns.Add("Column 4");
dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4");
//Populating the values to grid
this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, dataTable.Rows.Count, dataTable.Columns.Count), dataTable);
' Populating DataSource
Dim dataTable As New DataTable("Sample")
dataTable.Columns.Add("Column 1")
dataTable.Columns.Add("Column 2")
dataTable.Columns.Add("Column 3")
dataTable.Columns.Add("Column 4")
dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4")
'Populating the values to grid
Me.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, dataTable.Rows.Count, dataTable.Columns.Count), dataTable)
// Populating DataSource
DataTable dataTable = new DataTable("Sample");
dataTable.Columns.Add("Column 1");
dataTable.Columns.Add("Column 2");
dataTable.Columns.Add("Column 3");
dataTable.Columns.Add("Column 4");
dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4");
// Populating the headers
this.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, 4), dataTable);
' Populating DataSource
Dim dataTable As New DataTable("Sample")
dataTable.Columns.Add("Column 1")
dataTable.Columns.Add("Column 2")
dataTable.Columns.Add("Column 3")
dataTable.Columns.Add("Column 4")
dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4")
' Populating the headers
Me.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, 4), dataTable)
// Setting whole column's styles.
this.gridControl1.Model.ColStyles[1].BackColor = Color.Red;
this.gridControl1.Model.ColStyles[1].Font.Facename = "Segoe UI";
this.gridControl1.Model.ColStyles[1].Font.Bold = true;
' Setting whole column's styles.
Me.gridControl1.Model.ColStyles(1).BackColor = Color.Red
Me.gridControl1.Model.ColStyles(1).Font.Facename = "Segoe UI"
Me.gridControl1.Model.ColStyles(1).Font.Bold = True
// Setting whole Row�s styles.
this.gridControl1.Model. RowStyles[1].BackColor = Color.Red;
this.gridControl1.Model. RowStyles[1].Font.Facename = "Segoe UI";
this.gridControl1.Model. RowStyles[1].Font.Bold = true;
' Setting whole Row�s styles.
Me.gridControl1.Model.RowStyles(1).BackColor = Color.Red
Me.gridControl1.Model.RowStyles(1).Font.Facename = "Segoe UI"
Me.gridControl1.Model.RowStyles(1).Font.Bold = True
this.gridControl1.Model.TableStyle.TextColor = Color.Red;
this.gridControl1.Model.TableStyle.Font.Facename = "Segoe UI";
this.gridControl1.Model.TableStyle.Font.Size = 15;
Me.gridControl1.Model.TableStyle.TextColor = Color.Red
Me.gridControl1.Model.TableStyle.Font.Facename = "Segoe UI"
Me.gridControl1.Model.TableStyle.Font.Size = 15
GridStyleInfo style = GetCombinedStyle(GridRangeInfo.Cells(2, 2, 4, 8));
bool isBold = style.Font.Bold;
GridStyleInfo boldFontStyle = new GridStyleInfo();
boldFontStyle.TextColor = Color.FromArgb(238, 122, 3);
boldFontStyle.Font = boldFont;
model[rowIndex, 1].Text = "Interior";
model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle);
Dim boldFontStyle As New GridStyleInfo()
boldFontStyle.TextColor = Color.FromArgb(238, 122, 3)
boldFontStyle.Font = boldFont
model(rowIndex, 1).Text = "Interior"
model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle)
// The target range to set the text.
GridRangeInfo range = GridRangeInfo.Cols(1, 2);
//Setting the "SampleData" text to target range.
this.gridControl1.Model.ChangeCells(range, "SampleData");
' The target range to set the text.
Dim range As GridRangeInfo = GridRangeInfo.Cols(1, 2)
'Setting the "SampleData" text to target range.
Me.gridControl1.Model.ChangeCells(range, "SampleData")
// Defining the new cell styles.
GridStyleInfo newStyle = new GridStyleInfo();
newStyle.CellType = GridCellTypeName.ComboBox;
// Setting the styles of range of cells to new style.
this.gridControl1.Model.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle);
' Defining the new cell styles.
Dim newStyle As New GridStyleInfo()
newStyle.CellType = GridCellTypeName.ComboBox
' Setting the styles of range of cells to new style.
Me.gridControl1.Model.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle)
// Defining the new cell styles.
GridStyleInfo newStyle = new GridStyleInfo();
newStyle.CellType = GridCellTypeName.ComboBox;
// Setting the styles of range of cells to new style.
this.gridControl1.Model.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle, Syncfusion.Styles.StyleModifyType.Changes);
' Defining the new cell styles.
Dim newStyle As New GridStyleInfo()
newStyle.CellType = GridCellTypeName.ComboBox
' Setting the styles of range of cells to new style.
Me.gridControl1.Model.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle, Syncfusion.Styles.StyleModifyType.Changes)
GridStyleInfo style1 = new GridStyleInfo();
style2 = new GridStyleInfo();
style2.BackColor = Color.Red;
GridStyleInfo[] styles = { style1, style2 };
GridRangeInfo range = GridRangeInfo.Rows(6, 7);
this.gridControl1.Model.ChangeCells(range, styles);
Dim style1 As New GridStyleInfo()
style1.TextColor = Color.Blue
Dim style2 As New GridStyleInfo()
style2.BackColor = Color.Red
Dim styles() As GridStyleInfo = { style1, style2 }
Dim range As GridRangeInfo = GridRangeInfo.Rows(6, 7)
Me.gridControl1.Model.ChangeCells(range, styles)
// Defining the covered range.
GridRangeInfo coveredRange = GridRangeInfo.Cells(1, 2, 5, 5);
// Adding the range to be covered.
this.gridControl1.Model.CoveredRanges.Add(coveredRange);
//Finding range of covered cells.
GridRangeInfo range = this.gridControl1.Model.CoveredRanges.FindRange(e.RowIndex, e.ColIndex);
// Check whether the current cell is covered or not.
GridRangeInfo range;
if(this.gridControl1.Model.CoveredRanges.Find(e.RowIndex,e.ColIndex,out range))
{
// TODO
// TODO
}
' Defining the covered range.
Dim coveredRange As GridRangeInfo = GridRangeInfo.Cells(1, 2, 5, 5)
' Adding the range to be covered.
Me.gridControl1.Model.CoveredRanges.Add(coveredRange)
'Finding range of covered cells.
Dim range As GridRangeInfo = Me.gridControl1.Model.CoveredRanges.FindRange(e.RowIndex, e.ColIndex)
'Check whether the current cell is covered or not.
Dim range As GridRangeInfo
If Me.gridControl1.Model.CoveredRanges.Find(e.RowIndex,e.ColIndex,range) Then
' TODO
' TODO
End If
//Specify the cell model to be added in the grid model with cell type name.
this.gridControl1.CellModels.Add("SampleCellType", new GridHeaderCellModel(this.gridControl1.Model));
// Set the added cell type to the cell.
this.gridControl1.Model.ColStyles[1].CellType = "SampleCellType";
'Specify the cell model to be added in the grid model with cell type name.
Me.gridControl1.Model.CellModels.Add("SampleCellType", New GridHeaderCellModel(Me.gridControl1.Model))
'Set the added cell type to the cell
Me.gridControl1.Model.ColStyles(1).CellType = "SampleCellType"
if (OnDefaultSizeChanging(new GridDefaultSizeChangingEventArgs(value)))
{
bool success = false;
int savedValue = DefaultSize;
try
{
defaultSize = value;
success = true;
if (model.CommandStack.ShouldGenerateUndoInfo)
model.CommandStack.Push(new GridModelSetDefaultSizeCommand(this, savedValue));
}
finally
{
OnDefaultSizeChanged(new GridDefaultSizeChangedEventArgs(savedValue, success));
}
}
private void GridQueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if(e.ColIndex > 0 && e.RowIndex > 0)
{
e.Style.CellValue = this.intArray[e.RowIndex - 1, e.ColIndex - 1];
e.Handled = true;
}
}
Private Sub GridQueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
If ((e.ColIndex > 0) AndAlso (e.RowIndex > 0)) Then
e.Style.CellValue = Me.intArray(e.RowIndex - 1, e.ColIndex - 1)
e.Handled = True
End If
End Sub
this.gridControl1.GridVisualStyles = GridVisualStyles.Office2007Blue;
Me.GridControl1.GridVisualStyles = GridVisualStyles.Office2007Blue
gridControl1.Selections.SelectRange(GridRangeInfo.Row(1), true);
gridControl1.Selections.SetSelectClickRowCol(1, 0);
model.ColStyles[2].Font.Bold = true;
model.ColStyles[2].Font.Size = 16;
model.ColStyles[2].HorizontalAlignment = GridHorizontalAlignment.Center;
model.ColStyles[2].VerticalAlignment = GridVerticalAlignment.Middle;
model.ColStyles[2].CellType = "Static";
model.ColStyles[2].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(100, 238, 122, 3));
model.ColStyles[2].Interior = new BrushInfo(GradientStyle.PathEllipse, Color.FromArgb(100, 57, 73, 122), Color.FromArgb(237, 240, 247));
If you query for specific attributes in a cell and these attributes have not been explicitly set,
the
model.ColStyles[1].TextColor = Color.FromArgb(0, 21, 84);
Color color = model[1, 1].TextColor;
// model[1, 1].TextColor will return Color.FromArgb(0, 21, 84));
model.RowStyles[2].Font.Bold = true;
model.RowStyles[2].Font.Size = 16;
model.RowStyles[2].HorizontalAlignment = GridHorizontalAlignment.Center;
model.RowStyles[2].VerticalAlignment = GridVerticalAlignment.Middle;
model.RowStyles[2].CellType = "Static";
model.RowStyles[2].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(100, 238, 122, 3));
model.RowStyles[2].Interior = new BrushInfo(GradientStyle.PathEllipse, Color.FromArgb(100, 57, 73, 122), Color.FromArgb(237, 240, 247));
If you query for specific attributes in a cell and these attributes have not been explicitly set for the cell,
the
model.RowStyles[1].TextColor = Color.FromArgb(0, 21, 84);
Color color = model[1, 1].TextColor;
// model[1, 1].TextColor will return Color.FromArgb(0, 21, 84));
GridRangeInfo cellRange = GridRangeInfo.Cell(4, 5);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Cell(4, 5)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
GridRangeInfo cellRange = GridRangeInfo.Cells(3, 4, 6, 7);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Cells(3, 4, 6, 7)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
GridRangeInfo cellRange = GridRangeInfo.Row(3);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Row(3)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
GridRangeInfo cellRange = GridRangeInfo.Rows(3, 4);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Rows(3, 4)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
GridRangeInfo cellRange = GridRangeInfo.Col(3);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Col(3)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
GridRangeInfo cellRange = GridRangeInfo.Cells(3, 4);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Cells(3, 4)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
GridRangeInfo cellRange = GridRangeInfo.Auto(4, 5);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Auto(4, 5)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
GridRangeInfo cellRange = GridRangeInfo.Auto(2, 5, 4, 6);
this.gridControl1.Model.CoveredRanges.Add(cellRange);
Dim cellRange As GridRangeInfo = GridRangeInfo.Auto(2, 5, 4, 6)
Me.gridControl1.Model.CoveredRanges.Add(cellRange)
GridRangeInfo firstRange = new GridRangeInfo(1, 1, 100, 100);
...
GridRangeInfo firstRange = new GridRangeInfo(0, 0, 100, 100);
GridRangeInfo firstRange = new GridRangeInfo(0, 0, 100, 100);
GridStyleInfo standard = model.BaseStylesMap["Standard"].StyleInfo;
GridStyleInfo header = model.BaseStylesMap["Header"].StyleInfo;
GridStyleInfo rowHeader = model.BaseStylesMap["Row Header"].StyleInfo;
GridStyleInfo colHeader = model.BaseStylesMap["Column Header"].StyleInfo;
standard.TextColor = Color.FromArgb(0, 21, 84);
header.Interior = new BrushInfo(GradientStyle.Vertical, Color.FromArgb(238, 234, 216), Color.FromArgb(203, 199, 184));
rowHeader.Interior = new BrushInfo(GradientStyle.Horizontal, Color.FromArgb(238, 234, 216), Color.FromArgb(203, 199, 184));
standard.Font.Facename = "Helvetica";
standard.Interior = new BrushInfo(Color.FromArgb(237, 240, 247));
GridStyleInfo customStyle = model.BaseStylesMap["Custom Style"].StyleInfo;
standard.Interior = new BrushInfo(Color.Green);
model[1, 1].BaseStyle = "Custom Style";
GridStyleInfo standard = model.BaseStylesMap["Standard"].StyleInfo;
GridStyleInfo header = model.BaseStylesMap["Header"].StyleInfo;
GridStyleInfo rowHeader = model.BaseStylesMap["Row Header"].StyleInfo;
GridStyleInfo colHeader = model.BaseStylesMap["Column Header"].StyleInfo;
standard.TextColor = Color.FromArgb(0, 21, 84);
header.Interior = new BrushInfo(GradientStyle.Vertical, Color.FromArgb(238, 234, 216), Color.FromArgb(203, 199, 184));
rowHeader.Interior = new BrushInfo(GradientStyle.Horizontal, Color.FromArgb(238, 234, 216), Color.FromArgb(203, 199, 184));
standard.Font.Facename = "Helvetica";
standard.Interior = new BrushInfo(Color.FromArgb(237, 240, 247));
GridStyleInfo customStyle = model.BaseStylesMap["Custom Style"].StyleInfo;
standard.Interior = new BrushInfo(Color.Green);
model[1, 1].BaseStyle = "Custom Style";
GridBorder border = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(57, 73, 122));
model[rowIndex, colIndex].Borders.Bottom = border;
model[rowIndex, colIndex].Borders.Right = border;
The following code hides grid lines for specific cells:
GridBorder border = new GridBorder(GridBorderStyle.None);
model[rowIndex, colIndex].Borders.Bottom = border;
model[rowIndex, colIndex].Borders.Right = border;
this.gridControl1.TableStyle.Borders.All = new GridBorder(GridBorderStyle.Dotted, Color.SkyBlue);
Me.gridControl1.TableStyle.Borders.All = New GridBorder(GridBorderStyle.Dotted, Color.SkyBlue)
this.gridControl1.TableStyle.Borders.All = new GridBorder(GridBorderStyle.Dotted, Color.SkyBlue,GridBorderWeight.ExtraThick);
Me.gridControl1.TableStyle.Borders.All = New GridBorder(GridBorderStyle.Dotted, Color.SkyBlue)
GridBorder border = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(57, 73, 122));
model[rowIndex, colIndex].Borders.Bottom = border;
model[rowIndex, colIndex].Borders.Right = border;
The following code hides grid lines for specific cells:
GridBorder border = new GridBorder(GridBorderStyle.None);
model[rowIndex, colIndex].Borders.Bottom = border;
model[rowIndex, colIndex].Borders.Right = border;
model[2, 2].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(100, 238, 122, 3));
this.gridControl1.TableStyle.CellAppearance = GridCellAppearance.Flat;
Me.gridControl1.TableStyle.CellAppearance = GridCellAppearance.Flat
model[rowIndex, 1].Text = "Positive numbers";
RowStyles[rowIndex].CustomStyleProperties.Add(new GridValidateNumberStyleProperty(true, 1, float.NaN, "Please enter a number greater than 0!"));
model.RowStyles[rowIndex].ValidateValue.NumberRequired = true;
model.RowStyles[rowIndex].ValidateValue.Minimum = 0;
model.RowStyles[rowIndex].ValidateValue.Maximum = float.NaN;
model.RowStyles[rowIndex].ValidateValue.ErrorMessage = "Please enter a number greater than 0!";
rowIndex++;
model[rowIndex, 1].Text = "Validation (1-100 valid range)";
model.RowStyles[rowIndex].ValidateValue = new GridCellValidateValueInfo(true, 1, 100, "Please enter a number between 1 and 100!");
model.TableStyle.CheckBoxOptions = new GridCheckBoxCellInfo("True", "False", string.Empty, false);
model[rowIndex, 1].CheckBoxOptions.FlatLook = true;
//Scroll position based on the column index.
this.gridControl1.TableStyle.CheckBoxOptions = new GridCheckBoxCellInfo("Checked", "UnChecked", "Intermediate", true);
'Scroll position based on the column index.
Me.gridControl1.TableStyle.CheckBoxOptions = New GridCheckBoxCellInfo("Checked", "UnChecked", "Intermediate", True)
//Default currency symbol "$".
this.gridControl1.TableStyle.CurrencyEdit.CurrencySymbol = "�";
'Default currency symbol "$".
Me.gridControl1.TableStyle.CurrencyEdit.CurrencySymbol = "�"
this.gridControl1.TableStyle.CurrencyEdit.NegativeColor = Color.Red;
this.gridControl1.TableStyle.CurrencyEdit.NegativeColor = Color.Red;
model[rowIndex, colIndex].Font.Facename = "Arial";
model[rowIndex, colIndex].Font.Bold = true;
Font font = new Font("Segoe UI", 9.5f);
this.gridControl1.TableStyle.Font = new GridFontInfo(font);
Dim font As New Font("Segoe UI", 9.5f)
Me.gridControl1.TableStyle.Font = New GridFontInfo(font)
GridStyleInfo standard = model.BaseStylesMap["Standard"].StyleInfo;
Font dfont = Control.DefaultFont;
standard.Font.Unit = GraphicsUnit.World;
standard.Font.Facename = dfont.Name;
standard.Font.Size = GridFontInfo.SizeInWorldUnit(dfont);
Dim standard As GridStyleInfo = model.BaseStylesMap("Standard").StyleInfo
Dim dfont As Font = Control.DefaultFont
standard.Font.Unit = GraphicsUnit.World
standard.Font.Facename = dfont.Name
standard.Font.Size = GridFontInfo.SizeInWorldUnit(dfont)
this.gridControl1.TableStyle.HorizontalAlignment = GridHorizontalAlignment.Center;
Me.gridControl1.TableStyle.HorizontalAlignment = GridHorizontalAlignment.Center
GridMargins margins = new GridMargins(1, 1, 2, 2);
model[rowIndex, colIndex].Margins = new GridMarginsInfo(margins);
model[rowIndex, colIndex+1].Margins.Right = 2;
model[rowIndex, colIndex+1].Margins.Left = 2;
this.gridControl1[4, 8].CellType = GridCellTypeName.MaskEdit;
this.gridControl1[4, 8].MaskEdit.Mask = "###-###########";
//sets the character that will be used instead of mask characters when the mask position has not been filled.
this.gridControl1.TableStyle.MaskEdit.PaddingCharacter = 'T';
Me.gridControl1(4, 8).CellType = GridCellTypeName.MaskEdit
Me.gridControl1(4, 8).MaskEdit.Mask = "###-###########"
'sets the character that will be used instead of mask characters when the mask position has not been filled.
Me.gridControl1.TableStyle.MaskEdit.PaddingCharacter = "T"
model.TableStyle.NumericUpDown = new GridNumericUpDownCellInfo(0, 25, 1, 1, true);
model[rowIndex, 1].Text = "NumericUpDown";
// Wrapping, Range 0-1000
model[rowIndex, 3].CellType = "NumericUpDown";
model[rowIndex, 3].NumericUpDown = new GridNumericUpDownCellInfo(0, 1000, 0, 1, true);
// Disabled
model[rowIndex, 4].CellType = "NumericUpDown";
model[rowIndex, 4].Enabled = false;
model[rowIndex, 4].Text = "5";
// No wrapping, Range 1-20
model[rowIndex, 5].CellType = "NumericUpDown";
model[rowIndex, 5].NumericUpDown = new GridNumericUpDownCellInfo(1, 20, 1, 1, false);
rowIndex++;
this.gridControl1.TableStyle.NumericUpDown = new GridNumericUpDownCellInfo(0, 1000, 5, 5, false);
Me.gridControl1.TableStyle.NumericUpDown = New GridNumericUpDownCellInfo(0, 1000, 5, 5, False)
Color c = Color.Red;
Color c1 = Color.Black;
Color[] color = new Color[] { c, c1 };
this.gridControl1.TableStyle.ProgressBar.MultipleColors = color;
Dim c As Color = Color.Red
Dim c1 As Color = Color.Black
Dim color() As Color = { c, c1 }
Me.gridControl1.TableStyle.ProgressBar.MultipleColors = color
//Align the progress bar.
this.gridControl1.TableStyle.ProgressBar.ProgressOrientation = Orientation.Horizontal;
this.gridControl.TableStyle.ProgressBar.TextOrientation = Orientation.Vertical;
//Set the foreground styles for progress bar.
this.gridControl1.TableStyle.ProgressBar.ProgressStyle = ProgressBarStyles.Tube;
//set the progress bar style.
this.gridControl1.TableStyle.ProgressBar.ProgressFallbackStyle = ProgressBarStyles.Metro;
//sets the style of the background when BackgroundStyle is set to System and the system can not support Themes.
this.gridControl1.TableStyle.ProgressBar.BackgroundFallbackStyle = ProgressBarBackgroundStyles.System;
'sets the style of the background when BackgroundStyle is set to System and the system can not support Themes.
Me.gridControl1.TableStyle.ProgressBar.BackgroundFallbackStyle = ProgressBarBackgroundStyles.System
model[2, 2].Text = "Grid Demo";
model[2, 2].Font.Bold = True;
model[2, 2].Font.Size = 16;
model[2, 2].HorizontalAlignment = GridHorizontalAlignment.Center;
model[2, 2].VerticalAlignment = GridVerticalAlignment.Middle;
model[2, 2].CellType = "Static";
model[2, 2].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(100, 238, 122, 3));
model[2, 2].Interior = new BrushInfo(GradientStyle.PathEllipse, Color.FromArgb(100, 57, 73, 122), Color.FromArgb(237, 240, 247));
If you query for specific attributes in a cell and these attributes have not been explicitly set for the cell,
the
GridStyleInfo standard = model.BaseStylesMap["Standard"].StyleInfo;
standard.TextColor = Color.FromArgb(0, 21, 84);
Color color = model[1, 1].TextColor;
// model[1, 1].TextColor will return Color.FromArgb(0, 21, 84));
//Get the grid model.
GridModel model = this.gridControl1.TableStyle.GetGridModel();
'Get the grid model.
Dim model As GridModel= Me.gridControl1.TableStyle.GetGridModel()
this.gridControl1.Model.RowStyles[row - 1].Borders.Bottom = new GridBorder(GridBorderStyle.Solid, c, GridBorderWeight.ExtraExtraThick);
this.gridControl1.Model.ColStyles[col - 1].Borders.Right = new GridBorder(GridBorderStyle.Solid, c, GridBorderWeight.ExtraExtraThick);
GridBordersInfo b = this.gridControl1.Model[row - 1, col - 1].ReadOnlyBorders;
Console.WriteLine(b.Right); // will return Default since ReadOnlyBorders is RowStyles[row - 1].Borders which
has no knowledge about ColStyles if FixSubObjectsDerivedFromRowandColStyle = false.
Setting FixSubObjectsDerivedFromRowandColStyle = true fixes the problem.
//Setting the back color for GridTable.
this.gridControl1.TableStyle.BackColor = Color.Red;
'Setting the back color for GridTable.
Me.gridControl1.TableStyle.BackColor = Color.Red
//sets how text is trimmed when it exceeds the edges of the cell text rectangle.
this.gridControl1.TableStyle.Trimming = StringTrimming.EllipsisPath;
'sets how text is trimmed when it exceeds the edges of the cell text rectangle.
Me.gridControl1.TableStyle.Trimming = StringTrimming.EllipsisPath
//Set the character case
this.gridControl1.TableStyle.CharacterCasing = CharacterCasing.Upper;
'Set the character case
Me.gridControl1.TableStyle.CharacterCasing = CharacterCasing.Upper
//Set the vertical alignment for text in a cell.
this.gridControl1.TableStyle.VerticalAlignment = GridVerticalAlignment.Middle;
'Set the vertical alignment for text in a cell.
Me.gridControl1.TableStyle.VerticalAlignment = GridVerticalAlignment.Middle
this.gridControl1.TableStyle.TextAlign = GridTextAlign.Right;
Me.gridControl1.TableStyle.TextAlign = GridTextAlign.Right;
//Set the Cell Appearance.
this.gridControl1.TableStyle.CellAppearance = GridCellAppearance.Sunken;
'Set the Cell Appearance.
Me.gridControl1.TableStyle.CellAppearance = GridCellAppearance.Sunken
//Display special characters when the contents in cell exceeds it's width.
this.gridControl1.TableStyle.AutoFit = AutoFitOptions.Alphabet;
this.gridControl1.TableStyle.AutoFit = AutoFitOptions.Numeric;
this.gridControl1.TableStyle.AutoFit = AutoFitOptions.Both;
this.gridControl1.TableStyle.AutoFit = AutoFitOptions.None;
'Display special characters when the contents in cell exceeds it's width.
Me.gridControl1.TableStyle.AutoFit = AutoFitOptions.Alphabet
Me.gridControl1.TableStyle.AutoFit = AutoFitOptions.Numeric
Me.gridControl1.TableStyle.AutoFit = AutoFitOptions.Both
Me.gridControl1.TableStyle.AutoFit = AutoFitOptions.None
//Resets the AutoFit property.
this.gridControl1.TableStyle.ResetAutoFit();
'Resets the AutoFit property.
Me.gridControl1.TableStyle.ResetAutoFit()
//Display special characters when the contents in cell exceeds it's width.
this.gridControl1.TableStyle.AutoFit = AutoFitOptions.Alphabet;
//Set the character to display when the contents in cell exceeds it's width.
this.gridControl1.TableStyle.AutoFitChar = 's';
'Display special characters when the contents in cell exceeds it's width.
Me.gridControl1.TableStyle.AutoFit = AutoFitOptions.Alphabet
'Set the character to display when the contents in cell exceeds it's width.
this.gridControl1.TableStyle.AutoFitChar = 's';
//Resets the AutoFitChar property.
this.gridControl1.TableStyle.ResetAutoFitChar ();
'Resets the AutoFitChar property.
Me.gridControl1.TableStyle.ResetAutoFitChar ()
//Getting CultureInfo of Grid.
CultureInfo cultureInfo = this.gridControl1.TableStyle.GetCulture(true);
'Getting CultureInfo of Grid.
Dim cultureInfo As CultureInfo = Me.gridControl1.TableStyle.GetCulture(True)
Image image = Image.FromFile(@"\...\...\FileName.jpg");
this.gridControl1.TableStyle.BackgroundImage = image;
Dim image As Image = Image.FromFile("\...\...\FileName.jpg")
Me.gridControl1.TableStyle.BackgroundImage = image
GridControl grid = new GridControl();
GridStyleInfo style = new GridStyleInfo();
// using ctor with existing style object and caching the object (both C# and VB)
MyCustomStyleProperties mcs = new MyCustomStyleProperties(style);
mcs.TheLocked = true;
mcs.TheFont.Bold = true;
// design time code (both C# and VB)
MyCustomStyleProperties myCustomStyleProperties1 = new MyCustomStyleProperties();
myCustomStyleProperties1.TheLocked = true;
myCustomStyleProperties1.TheFont.Bold = true;
style.CustomProperties.Add(myCustomStyleProperties1);
// using ctor with indexer (C# only)
(new MyCustomStyleProperties(grid[1,1])).TheLocked = true;
(new MyCustomStyleProperties(grid[1,1])).TheFont.Bold = true;
// using ctor with existing style object (C# only)
style.Text = "bla";
new MyCustomStyleProperties(style).TheLocked = true;
new MyCustomStyleProperties(style).TheFont.Bold = true;
// explicit case (C# only)
((MyCustomStyleProperties) style).TheLocked = true;
((MyCustomStyleProperties) style).TheFont.Bold = true;
Dim style As New GridStyleInfo()
Dim grid As New GridControl()
' using ctor with existing style object and caching the object (VB and C#)
Dim mcs As New MyCustomStyleProperties(style)
mcs.TheLocked = True
mcs.TheFont.Bold = True
' design time code (VB and C#)
Dim myCustomStyleProperties1 As New MyCustomStyleProperties()
myCustomStyleProperties1.TheLocked = True
myCustomStyleProperties1.TheFont.Bold = True
style.CustomProperties.Add(myCustomStyleProperties1)
' with operator (Visual Basic only)
With New MyCustomStyleProperties(style)
.TheLocked = True
.TheFont.Bold = True
End With
' with operator (Visual Basic only)
With New MyCustomStyleProperties(grid(1, 1))
.TheLocked = True
.TheFont.Bold = True
End With
using System;
using System.ComponentModel;
using Syncfusion.Diagnostics;
using Syncfusion.Styles;
using Syncfusion.Windows.Forms;
using Syncfusion.Windows.Forms.Grid;
namespace WindowsApplication1
{
public class MyCustomStyleProperties : GridStyleInfoCustomProperties
{
// static initialization of property descriptors
static Type t = typeof(MyCustomStyleProperties);
readonly static StyleInfoProperty LockedProperty = CreateStyleInfoProperty(t, "TheLocked");
readonly static StyleInfoProperty TheFontProperty = CreateStyleInfoProperty(t, "TheFont");
// default settings for all properties this object holds
static MyCustomStyleProperties defaultObject;
// initialize default settings for all properties in static ctor
static MyCustomStyleProperties ()
{
// all properties must be initialized for the Default property
defaultObject = new MyCustomStyleProperties(GridStyleInfo.Default);
defaultObject.TheLocked = true;
defaultObject.TheFont = GridFontInfo.Default;
}
///
/// Provides access to default values for this type.
///
public static MyCustomStyleProperties Default
{
get
{
return defaultObject;
}
}
///
/// Force static ctor being called at least once.
///
public static void Initialize()
{
}
// Explicit cast from GridStyleInfo to MyCustomStyleProperties.
// (Note: this will only work for C#, Visual Basic does not support dynamic casts.)
///
/// Explicit cast from GridStyleInfo to this custom property object.
///
/// A new custom properties object.
public static explicit operator MyCustomStyleProperties(GridStyleInfo style)
{
return new MyCustomStyleProperties(style);
}
///
/// Initializes a MyCustomStyleProperties object with a style object that holds all data.
///
public MyCustomStyleProperties(GridStyleInfo style)
: base(style)
{
}
///
/// Initializes a MyCustomStyleProperties object with an empty style object. Design-
/// time environment will use this ctor and later copy the values to a style object
/// by calling style.CustomProperties.Add(otherCustomStyleProperties1).
///
public MyCustomStyleProperties()
: base()
{
}
///
/// Gets / sets TheLocked state.
///
[
Description("Specifies if ..."),
Browsable(true),
Category("StyleCategoryBehavior")
]
public bool TheLocked
{
get
{
TraceUtil.TraceCurrentMethodInfo();
return (bool) style.GetValue(LockedProperty);
}
set
{
TraceUtil.TraceCurrentMethodInfo(value);
style.SetValue(LockedProperty, value);
}
}
///
/// Resets TheLocked state.
///
public void ResetTheLocked()
{
style.ResetValue(LockedProperty);
}
[EditorBrowsableAttribute(EditorBrowsableState.Never)]
private bool ShouldSerializeTheLocked()
{
return style.HasValue(LockedProperty);
}
///
/// Gets if TheLocked state has been initialized for the current object.
///
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool HasTheLocked
{
get
{
return style.HasValue(LockedProperty);
}
}
///
/// Gets / sets TheFont state. TheFont is itself an expandable object
/// with several properties that can be set individually and participate
/// in style inheritance mechanism.
///
[
Description("The font for drawing text."),
Browsable(true),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
Category("StyleCategoryAppearance")
]
public GridFontInfo TheFont
{
get
{
return (GridFontInfo) style.GetValue(TheFontProperty);
}
set
{
style.SetValue(TheFontProperty, value);
}
}
///
/// Resets TheFont state.
///
public void ResetTheFont()
{
style.ResetValue(TheFontProperty);
}
[EditorBrowsableAttribute(EditorBrowsableState.Never)]
private bool ShouldSerializeTheFont()
{
return style.HasValue(TheFontProperty);
}
///
/// Determines if TheFont state has been initialized for the current object.
///
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool HasTheFont
{
get
{
return style.HasValue(TheFontProperty);
}
}
}
public class MyGridControl : GridControl
{
public MyGridControl()
{
// force static ctor of MyCustomStyleProperties being called at least once
MyCustomStyleProperties.Initialize();
}
}
}
Public Class MyCustomStyleProperties
Inherits GridStyleInfoCustomProperties
' static initialization of property descriptors
Private Shared t As Type = GetType(MyCustomStyleProperties)
Private Shared LockedProperty As StyleInfoProperty = CreateStyleInfoProperty(t, "TheLocked")
Private Shared TheFontProperty As StyleInfoProperty = CreateStyleInfoProperty(t, "TheFont")
' default settings for all properties this object holds
Private Shared defaultObject As MyCustomStyleProperties
' initialize default settings for all properties in static ctor
Shared Sub New()
' all properties must be initialized for the Default property
defaultObject = New MyCustomStyleProperties(GridStyleInfo.Default)
defaultObject.TheLocked = True
defaultObject.TheFont = GridFontInfo.Default
End Sub 'New
'/
'/ Provides access to default values for this type
'/
Public Shared ReadOnly Property [Default]() As MyCustomStyleProperties
Get
Return defaultObject
End Get
End Property
'/
'/ Force static ctor being called at least once.
'/
Public Shared Sub Initialize()
End Sub 'Initialize
'/
'/ Initializes a MyCustomStyleProperties object with a style object that holds all data.
'/
Public Sub New(ByVal style As GridStyleInfo)
MyBase.New(style)
End Sub 'New
'/
'/ Initializes a MyCustomStyleProperties object with an empty style object. Design-
'/ time environment will use this ctor and later copy the values to a style object
'/ by calling style.CustomProperties.Add(otherCustomStyleProperties1).
'/
Public Sub New()
End Sub 'New
'/
'/ Gets / sets TheLocked state.
'/
'Description("Specifies if ..."), Browsable(True), Category("StyleCategoryBehavior")> _
Public Property TheLocked() As Boolean
Get
TraceUtil.TraceCurrentMethodInfo()
Return CBool(style.GetValue(LockedProperty))
End Get
Set(ByVal Value As Boolean)
TraceUtil.TraceCurrentMethodInfo(Value)
style.SetValue(LockedProperty, Value)
End Set
End Property
'/
'/ Resets TheLocked state.
'/
Public Sub ResetTheLocked()
style.ResetValue(LockedProperty)
End Sub 'ResetTheLocked
'EditorBrowsableAttribute(EditorBrowsableState.Never)> _
Private Function ShouldSerializeTheLocked() As Boolean
Return style.HasValue(LockedProperty)
End Function 'ShouldSerializeTheLocked
'/
'/ Gets if TheLocked state has been initialized for the current object.
'/
'Browsable(False), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public ReadOnly Property HasTheLocked() As Boolean
Get
Return style.HasValue(LockedProperty)
End Get
End Property
'/
'/ Gets / sets TheFont state. TheFont is itself an expandable object
'/ with several properties that can be set individually and participate
'/ in style inheritance mechanism.
'/
'Description("The font for drawing text."), Browsable(True), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("StyleCategoryAppearance")> _
Public Property TheFont() As GridFontInfo
Get
Return CType(style.GetValue(TheFontProperty), GridFontInfo)
End Get
Set(ByVal Value As GridFontInfo)
style.SetValue(TheFontProperty, Value)
End Set
End Property
'/
'/ Resets TheFont state.
'/
Public Sub ResetTheFont()
style.ResetValue(TheFontProperty)
End Sub 'ResetTheFont
'EditorBrowsableAttribute(EditorBrowsableState.Never)> _
Private Function ShouldSerializeTheFont() As Boolean
Return style.HasValue(TheFontProperty)
End Function 'ShouldSerializeTheFont
'/
'/ Determines if TheFont state has been initialized for the current object.
'/
'Browsable(False), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public ReadOnly Property HasTheFont() As Boolean
Get
Return style.HasValue(TheFontProperty)
End Get
End Property
End Class 'MyCustomStyleProperties
standard.Font.Facename = "Helvetica";
model[1, 3].Font.Bold = true;
string faceName = model[1, 3].Font.Facename; // any cell inherits standard style
Console.WriteLIne(faceName); // will output "Helvetica"
Console.WriteLIne(model[1, 3].Font.Bold); // will output "true"
Console.WriteLIne(model[1, 3].Font.HasFaceName); // will output "False"
//Get the grid model.
GridModel model = this.gridControl1.TableStyle.GetGridModel();
'Get the grid model.
Dim model As GridModel= Me.gridControl1.TableStyle.GetGridModel()
protected virtual Control CreateInnerControl(out GridControlBase grid)
{
grid = Grid.CreateNewControl(this.dropdownContainer, 0, 0) as GridControlBase;
grid.Dock = DockStyle.Fill;
grid.DropDownContainerParent = this.dropdownContainer;
GridRecordNavigationControl recordNavigationControl1 = null;
recordNavigationControl1 = new GridRecordNavigationControl (grid);
recordNavigationControl1.Dock = DockStyle.Fill;
recordNavigationControl1.TabIndex = 0;
return recordNavigationControl1;
}
GridNumericUpDownCellModel cm = (GridNumericUpDownCellModel) this.gridControl1.CellModels["NumericUpDown"];
cm.AcceptAlphaKeys = false;
Dim cm As GridNumericUpDownCellModel = CType(Me.gridControl1.CellModels("NumericUpDown"), GridNumericUpDownCellModel)
cm.AcceptAlphaKeys = False
// Resizing and selecting functionality of row and column will be enabled for grid. Other functionalities like Clicking, OleDropTarget ..etc will not be worked.
this.gridControl1.ControllerOptions = GridControllerOptions.ResizeCells | GridControllerOptions.SelectCells;
' Resizing and selecting functionality of row and column will be enabled for grid. Other functionalities like Clicking, OleDropTarget ..etc will not be worked.
Me.gridControl1.ControllerOptions = (GridControllerOptions.ResizeCells Or GridControllerOptions.SelectCells)
// TextColor for all the grid cells will be changed to Blue
this.gridControl1.BaseStylesMap["Standard"].StyleInfo.TextColor = Color.Blue;
// Backcolor for all the header cells (Row and Column) will be changed as "Red"
this.gridControl1.BaseStylesMap["Header"].StyleInfo.BackColor = Color.Red;
' TextColor for all the grid cells will be changed to Blue
Me.gridControl1.BaseStylesMap["Standard"].StyleInfo.TextColor = Color.Blue
' Backcolor for all the header cells (Row and Column) will be changed as "Red"
Me.gridControl1.BaseStylesMap["Header"].StyleInfo.BackColor = Color.Red
// Hiding the first row.
this.gridControl1.HideRows[1] = true;
// Removing the first row from hidden.
this.gridControl1.HideRows [3] = false;
' Hiding the first row.
Me.gridControl1.HideRows[1] = true
' Removing the first row from hidden.
Me.gridControl1.HideRows [3] = false
// Hiding the first column.
this.gridControl1.HideCols[1] = true;
// Removing the second column from hidden.
this.gridControl1.HideCols[4] = false;
' Hiding the first column.
Me.gridControl1.HideCols[1] = true
' Removing the second column from hidden.
Me.gridControl1.HideCols[4] = false
// Undo the actions in the grid.
this.gridControl1.CommandStack.Undo();
//Redo the actions in the grid.
this.gridControl1.CommandStack.Redo();
// Getting the current command mode of the grid.
GridCommandMode commandMode = this.gridControl1.CommandStack.Mode;
' Undo the actions in the grid.
Me.gridControl1.CommandStack.Undo()
' Redo the actions in the grid.
Me.gridControl1.CommandStack.Redo()
' Getting the current command mode of the grid.
Dim commandMode As GridCommandMode = Me.gridControl1.CommandStack.Mode
// Setting whole column's styles.
this.gridControl1.ColStyles[1].BackColor = Color.Red;
this.gridControl1.ColStyles[1].Font.Facename = "Segoe UI";
this.gridControl1.ColStyles[1].Font.Bold = true;
' Setting whole column's styles.
Me.gridControl1.ColStyles[1].BackColor = Color.Red
Me.gridControl1.ColStyles[1].Font.Facename = "Segoe UI"
Me.gridControl1.ColStyles[1].Font.Bold = true
// Setting styles for the whole row with the specific row index.
this.gridControl1.RowStyles[1].BackColor = Color.Red;
this.gridControl1.RowStyles[1].Font.Facename = "Segoe UI";
this.gridControl1.RowStyles[1].Font.Bold = true;
' Setting styles for the whole row with the specific row index.
Me.gridControl1.RowStyles(1).BackColor = Color.Red
Me.gridControl1.RowStyles(1).Font.Facename = "Segoe UI"
Me.gridControl1.RowStyles(1).Font.Bold = true
this.gridControl1.TableStyle.TextColor = Color.Red;
this.gridControl1.TableStyle.Font.Facename = "Segoe UI";
this.gridControl1.TableStyle.Font.Size = 15;
Me.gridControl1.TableStyle.TextColor = Color.Red
Me.gridControl1.TableStyle.Font.Facename = "Segoe UI"
Me.gridControl1.TableStyle.Font.Size = 15
// Defining the covered range.
GridRangeInfo coveredRange = GridRangeInfo.Cells(1, 2, 5, 5);
// Adding the range to be covered.
this.gridControl1.CoveredRanges.Add(coveredRange);
' Defining the covered range.
Dim coveredRange As GridRangeInfo = GridRangeInfo.Cells(1, 2, 5, 5)
' Adding the range to be covered.
Me.gridControl1.CoveredRanges.Add(coveredRange)
//Specify the cell model to be added in the grid model with cell type name.
this.gridControl1.CellModels.Add("SampleCellType", new GridHeaderCellModel(this.gridControl1.Model));
// Set the added cell type to the cell.
this.gridControl1.ColStyles[1].CellType = "SampleCellType";
' Specify the cell model to be added in the grid model with cell type name.
Me.gridControl1.CellModels.Add("SampleCellType", new GridHeaderCellModel(this.gridControl1.Model))
' Set the added cell type to the cell.
Me.gridControl1.ColStyles[1].CellType = "SampleCellType"
// Setting the mouse button mask to drag either using Left or Right mouse button.
this.gridControl1.DragSelectedCellsMouseButtonsMask = System.Windows.Forms.MouseButtons.Left | System.Windows.Forms.MouseButtons.Right;
' Setting the mouse button mask to drag either using Left or Right mouse button.
Me.gridControl1.DragSelectedCellsMouseButtonsMask = (System.Windows.Forms.MouseButtons.Left Or System.Windows.Forms.MouseButtons.Right)
// Setting grid's selection mode as MultiExtended
this.gridControl1.ListBoxSelectionMode = SelectionMode.MultiExtended;
' Setting grid control selection mode as MultiExtended
Me.gridControl1.ListBoxSelectionMode = SelectionMode.MultiExtended
// Current cell will be activated when clicking on a cell.
this.gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.ClickOnCell;
' Current cell will be activated when clicking on a cell.
Me.gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.ClickOnCell
// Moves the current cell to the bottom when pressing Enter key.
this.gridControl1.EnterKeyBehavior = GridDirectionType.Bottom;
' Moves the current cell to the bottom when pressing Enter key.
Me.gridControl1.EnterKeyBehavior = GridDirectionType.Bottom
//Current cell border will always visible
this.gridControl1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.AlwaysVisible;
'Current cell border will always visible
Me.gridControl1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.AlwaysVisible
// Populating DataSource
DataTable dataTable = new DataTable("Sample");
dataTable.Columns.Add("Column 1");
dataTable.Columns.Add("Column 2");
dataTable.Columns.Add("Column 3");
dataTable.Columns.Add("Column 4");
dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4");
Populating the values to grid.
this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, dataTable.Rows.Count, dataTable.Columns.Count), dataTable);
' Populating DataSource
Dim dataTable As DataTable = New DataTable("Sample")
dataTable.Columns.Add("Column 1")
dataTable.Columns.Add("Column 2")
dataTable.Columns.Add("Column 3")
dataTable.Columns.Add("Column 4")
dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4")
'Populating the values to grid.
this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, dataTable.Rows.Count, dataTable.Columns.Count), dataTable)
// Populating DataSource
DataTable dataTable = new DataTable("Sample");
dataTable.Columns.Add("Column 1");
dataTable.Columns.Add("Column 2");
dataTable.Columns.Add("Column 3");
dataTable.Columns.Add("Column 4");
dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4");
//Populating the headers
this.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, 4), dataTable);
' Populating DataSource
Dim dataTable As DataTable = New DataTable("Sample")
dataTable.Columns.Add("Column 1")
dataTable.Columns.Add("Column 2")
dataTable.Columns.Add("Column 3")
dataTable.Columns.Add("Column 4")
dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4")
' Populating the headers
Me.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, 4), dataTable)
// The target range to set the text.
GridRangeInfo range = GridRangeInfo.Cols(1, 2);
//Setting the "SampleData" text to target range.
this.gridControl1.ChangeCells(range, "SampleData");
' The target range to set the text.
Dim range As GridRangeInfo = GridRangeInfo.Cols(1, 2)
'Setting the "SampleData" text to target range.
Me.gridControl1.ChangeCells(range, "SampleData")
// Defining the new cell styles.
GridStyleInfo newStyle = new GridStyleInfo();
newStyle.CellType = GridCellTypeName.ComboBox;
// Setting the styles of range of cells to new style.
this.gridControl1.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle);
' Defining the new cell styles.
Dim newStyle As GridStyleInfo = New GridStyleInfo
newStyle.CellType = GridCellTypeName.ComboBox
// Setting the styles of range of cells to new style.
Me.gridControl1.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle)
// Defining the new cell styles.
GridStyleInfo newStyle = new GridStyleInfo();
newStyle.CellType = GridCellTypeName.ComboBox;
// Setting the styles of range of cells to new style.
this.gridControl1.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle, Syncfusion.Styles.StyleModifyType.Changes);
Dim newStyle As GridStyleInfo = New GridStyleInfo
newStyle.CellType = GridCellTypeName.ComboBox
' Setting the styles of range of cells to new style.
Me.gridControl1.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle, Syncfusion.Styles.StyleModifyType.Changes)
// Defining the new cell styles.
GridStyleInfo newStyle = new GridStyleInfo();
newStyle.CellType = GridCellTypeName.ComboBox;
// Setting the styles of range of cells to new style.
this.gridControl1.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle, Syncfusion.Styles.StyleModifyType.Changes);
' Defining the new cell styles.
Dim newStyle As GridStyleInfo = New GridStyleInfo
newStyle.CellType = GridCellTypeName.ComboBox
' Setting the styles of range of cells to new style.
Me.gridControl1.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle, Syncfusion.Styles.StyleModifyType.Changes)
GridStyleInfo style1 = new GridStyleInfo();
style1.TextColor = Color.Blue;
GridStyleInfo style2 = new GridStyleInfo();
style2.BackColor = Color.Red;
GridStyleInfo[] styles = new GridStyleInfo[] { style1, style2 };
GridRangeInfo range = GridRangeInfo.Rows(1,2);
this.gridControl1.ChangeCells(range, styles, Syncfusion.Styles.StyleModifyType.Remove);
Dim style1 As GridStyleInfo = New GridStyleInfo
style1.TextColor = Color.Blue
Dim style2 As GridStyleInfo = New GridStyleInfo
style2.BackColor = Color.Red
Dim styles() As GridStyleInfo = New GridStyleInfo() {style1, style2}
Dim range As GridRangeInfo = GridRangeInfo.Rows(1, 2)
Me.gridControl1.ChangeCells(range, styles, Syncfusion.Styles.StyleModifyType.Remove)
// Sets back-color depending on the index.
this.gridDataBoundGrid1.Model.ColStyles[1].BackColor = Color.Red;
' Sets back-color depending on the index.
Me.gridDataBoundGrid1.Model.ColStyles(1).BackColor = Color.Red
// Creates a column collection to be added to the grid.
GridBoundColumnsCollection myColumn = (GridBoundColumnsCollection)this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
// Creates the column to be added.
GridBoundColumn Column1 = new GridBoundColumn();
Column1.HeaderText = "NewColumn";
// Adds the created column to the collection.
myColumn.Add(Column1);
// Binds the created column collections to the grid bound columns.
this.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn;
' Creates a column to be added to the collection.
Dim myColumn1 As GridBoundColumnsCollection = CType(Me.gridDataBoundGrid1.Binder.InternalColumns.Clone(), GridBoundColumnsCollection)
Dim Column1 As New GridBoundColumn()
Column1.HeaderText = "NewColumn"
myColumn1.Add(Column1)
' Binds the created column to the grid bound columns.
Me.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn1
// Creates a column collection to be added to the grid.
GridBoundColumnsCollection myColumn = (GridBoundColumnsCollection)this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
// Declares the range of columns to be added.
GridBoundColumn[] Column1 = new GridBoundColumn[5];
// Initializes each instance of the GridBoundColumns.
Column1[i] = new GridBoundColumn();
Column1[0].HeaderText = "NewColumn 1";
Column1[1].HeaderText = "NewColumn 2";
Column1[2].HeaderText = "NewColumn 3";
Column1[3].HeaderText = "NewColumn 4";
Column1[4].HeaderText = "NewColumn 5";
// Binds the created column collections to the grid bound columns.
myColumn.AddRange(Column1);
this.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn;
' Creates a column collection to be added to the grid.
Dim myColumn As GridBoundColumnsCollection = CType(Me.gridDataBoundGrid1.Binder.InternalColumns.Clone(), GridBoundColumnsCollection)
' Declares the range of columns to be added.
Dim Column1(4) As GridBoundColumn
' Initializes each instance of the GridBoundColumns.
For i As Integer = 0 To Column1.Length - 1
Column1(i) = New GridBoundColumn()
Next i
Column1(0).HeaderText = "NewColumn 1"
Column1(1).HeaderText = "NewColumn 2"
Column1(2).HeaderText = "NewColumn 3"
Column1(3).HeaderText = "NewColumn 4"
Column1(4).HeaderText = "NewColumn 5"
' Binds the created column collections to the grid bound columns.
myColumn.AddRange(Column1)
Me.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn
// Creates a column collection to be added to the grid.
GridBoundColumnsCollection myColumn = (GridBoundColumnsCollection)this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
// Creates the column to be added.
GridBoundColumn Column1 = new GridBoundColumn();
Column1.HeaderText = "NewColumn";
// Inserts the created column to the collection at the specified index of the grid. Here "3" is the column index.
myColumn.Insert(3, Column1);
// Binds the created column collections to the grid bound columns.
this.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn;
' Creates a column collection to be added to the grid.
Dim myColumn As GridBoundColumnsCollection = CType(Me.gridDataBoundGrid1.Binder.InternalColumns.Clone(), GridBoundColumnsCollection)
' Creates the column to be added.
Dim Column1 As New GridBoundColumn()
Column1.HeaderText = "NewColumn"
' Inserts the created column to the collection at the specified index of the grid. Here "3" is the column index.
myColumn.Insert(3, Column1)
' Binds the created column collections to the grid bound columns.
Me.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn
// Removes the column using GridBoundColumn mapping name.
this.gridDataBoundGrid1.Binder.InternalColumns.Remove(Column1);
' Removes the column using GridBoundColumn mapping name.
Me.gridDataBoundGrid1.Binder.InternalColumns.Remove(Column1)
// Removes column at the given index in the grid. Here "3" is the column index.
this.gridDataBoundGrid1.Binder.InternalColumns.RemoveAt(3);
' Removes column at the given index in the grid. Here "3" is the column index.
Me.gridDataBoundGrid1.Binder.InternalColumns.RemoveAt(3)
// Sets the border line style
this.gridDataBoundGrid1.DefaultGridBorderStyle = GridBorderStyle.Solid;
' Sets the border line style
Me.gridDataBoundGrid1.DefaultGridBorderStyle = GridBorderStyle.Solid
// Sets the color of grid lines.
this.gridDataBoundGrid1.GridLineColor = Color.Red;
' Sets the color of grid lines.
Me.gridDataBoundGrid1.GridLineColor = Color.Red
public override Control CreateNewControl(Control parent, int row, int column)
{
MyGridDataBoundGrid grid = new MyGridDataBoundGrid((GridDataBoundGridModel) this.Model);
this.WireNewControl(grid);
return grid;
}
// Creates a column to be added to the collection.
GridBoundColumnsCollection myColumn1 = (GridBoundColumnsCollection)this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
GridBoundColumn Column1 = new GridBoundColumn();
Column1.HeaderText = "NewColumn";
myColumn1.Add(Column1);
// Binds the created column to the grid bound columns.
this.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn1;
' Creates a column to be added to the collection.
Dim myColumn1 As GridBoundColumnsCollection = CType(Me.gridDataBoundGrid1.Binder.InternalColumns.Clone(), GridBoundColumnsCollection)
Dim Column1 As New GridBoundColumn()
Column1.HeaderText = "NewColumn"
myColumn1.Add(Column1)
' Binds the created column to the grid bound columns.
Me.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn1
// Creates the data source.
DataTable dataTable = new DataTable();
// Assigns the data source to be displayed in the grid
this.gridDataBoundGrid1.DataSource = dataTable;
' Creates the data source.
Dim dataTable As New DataTable()
' Assigns the data source to be displayed in the grid
Me.gridDataBoundGrid1.DataSource = dataTable
private void gridDataBoundGrid3_ValidateFailed(object sender, GridValidateFailedEventArgs e)
{
TraceUtil.TraceCurrentMethodInfo(e);
GridCurrentCell cc = this.gridDataBoundGrid3.CurrentCell;
cc.Grid.CancelUpdate();
MessageBox.Show("My Error:" + cc.ErrorMessage);
cc.RejectChanges();
cc.ResetError();
}
// Sets the sorting behavior
this.gridDataBoundGrid1.SortBehavior = GridSortBehavior.DoubleClick;
' Sets the sorting behavior
Me.gridDataBoundGrid1.SortBehavior = GridSortBehavior.DoubleClick
// Deletes the records to a specific range.
this.gridDataBoundGrid1.DeleteRecordsAtRowIndex(5,10);
' Deletes the records to a specific range.
Me.gridDataBoundGrid1.DeleteRecordsAtRowIndex(5,10)
// Sets the current cell activation on double-clicking the cell.
this.gridDataBoundGrid1.ActivateCurrentCellBehavior = GridCellActivateAction.DblClickOnCell;
' Sets the current cell activation on double-clicking the cell.
Me.gridDataBoundGrid1.ActivateCurrentCellBehavior = GridCellActivateAction.DblClickOnCell
// Assigns a specific color for alpha-blend selection color
this.gridDataBoundGrid1.AlphaBlendSelectionColor = Color.SteelBlue;
' Assigns a specific color for alpha-blend selection color
Me.gridDataBoundGrid1.AlphaBlendSelectionColor = Color.SteelBlue
// Allows the selection of rows.
this.gridDataBoundGrid1.AllowSelection = GridSelectionFlags.Row;
// Disables the selection.
this.gridDataBoundGrid1.AllowSelection = GridSelectionFlags.None;
' Allows the selection of rows.
Me.gridDataBoundGrid1.AllowSelection = GridSelectionFlags.Row
' Disables the selection.
Me.gridDataBoundGrid1.AllowSelection = GridSelectionFlags.None
// To apply visual styles the themes enabled property should be set to true.
// Otherwise the default SystemTheme is applied.
this.gridDataBoundGrid1.ThemesEnabled = true;
// Applies the metro style to the grid.
this.gridDataBoundGrid1.GridVisualStyles = GridVisualStyles.Metro;
' Otherwise the default SystemTheme is applied.
' To apply visual styles the themes enabled property should be set to True
Me.gridDataBoundGrid1.ThemesEnabled = True
' Applies the metro style to the grid.
Me.gridDataBoundGrid1.GridVisualStyles = GridVisualStyles.Metro
// Sets the selection mode of the control.
this.gridDataBoundGrid1.ListBoxSelectionMode = SelectionMode.MultiExtended;
' Sets the selection mode of the control.
Me.gridDataBoundGrid1.ListBoxSelectionMode = SelectionMode.MultiExtended
// Only resizes the selected column or range.
this.gridDataBoundGrid1.ResizeColsBehavior = GridResizeCellsBehavior.ResizeSingle;
// Restrict resizing columns and the divider doesn't appear.
this.gridDataBoundGrid1.ResizeColsBehavior = GridResizeCellsBehavior.None;
' Only resizes the selected column or range.
Me.gridDataBoundGrid1.ResizeColsBehavior = GridResizeCellsBehavior.ResizeSingle
' Restrict resizing columns and the divider doesn't appear.
Me.gridDataBoundGrid1.ResizeColsBehavior = GridResizeCellsBehavior.None
// Shows the cell border like active current cell all the time.
this.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.AlwaysVisible;
// Shows gray color border when the grid is not active.
this.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.GrayWhenLostFocus;
' Shows the cell border like active current cell all the time.
Me.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.AlwaysVisible
' Shows gray color border when the grid is not active.
Me.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.GrayWhenLostFocus
//Show my own custom filter.
private void GridFilterBarShowDialogEventHandler(object send, GridFilterBarShowDialogEventArgs e)
{
MyFilterDialog dlg = new MyFilterDialog();
DialogResult result = dlg.ShowDialog();
if(result == DialogResult.Ignore)
{
//Show the default dialog.
e.Handled = false;
}
else
{
//Otherwise, don't show default and set the result.
e.Handled = true;
e.Result = result; //cancel or OK-filter the grid with e.FilterCriteria
e.FilterCriteria = dlg.textBox1.Text; // the filter string
}
}
// Creates the filter-bar instance.
GridFilterBar myFilterBar = new GridFilterBar();
// Wires the grid to the filter-bar.
myFilterBar.WireGrid(this.gridDataBoundGrid1);
' Creates the filter-bar instance.
Dim myFilterBar As New GridFilterBar()
' Wires the grid to the filter-bar.
myFilterBar.WireGrid(Me.gridDataBoundGrid1)
// Creates the filter-bar instance.
GridFilterBar myFilterBar = new GridFilterBar();
// Creates the GridStyleinfo instance and specifies the style properties.
GridStyleInfo myStyle1 = new GridStyleInfo();
myStyle1.BackColor = Color.WhiteSmoke;
myStyle1.Font.Italic = true;
myStyle1.Borders.All = new GridBorder(GridBorderStyle.Dashed);
myStyle1.ExclusiveChoiceList = true;
myStyle1.CellType = "ComboBox";
myStyle1.BaseStyle = "Standard";
myFilterBar.WireGrid(this.gridDataBoundGrid1, myStyle1);
' Creates the filter-bar instance.
Dim myFilterBar As New GridFilterBar()
' Creates the GridStyleinfo instance and specifies the style properties.
Dim myStyle1 As New GridStyleInfo()
myStyle1.BackColor = Color.WhiteSmoke
myStyle1.Font.Italic = True
myStyle1.Borders.All = New GridBorder(GridBorderStyle.Dashed)
myStyle1.ExclusiveChoiceList = True
myStyle1.CellType = "ComboBox"
myStyle1.BaseStyle = "Standard"
myFilterBar.WireGrid(Me.gridDataBoundGrid1, myStyle1)
public string[] GridFilterBarStrings = new string[]
{
"(none)", //0
"(custom)", //1
"equals", //2
"does not equal", //3
"is greater than", //4
"is greater than or equal to", //5
"is less than", //6
"is less than or equal to", //7
"begins with", //8
"does not begin with", //9
"ends with", //10
"does not end with", //11
"contains", //12
"does not contain", //13
"Use * to represent any series of characters", //14
"Show rows where:", //15
"Improper custom filter: ", //16
"I and " //17
};
///
/// A specialization of the GridBoundColumn class with additional
/// functionality.
///
public class CustomGridColumn : GridBoundColumn, ICloneable
{
private int width;
private int widthPercentage;
///
/// Default constructor.
///
public CustomGridColumn()
{
}
public int Width
{
get { return width; }
set { width = value; }
}
public int WidthPercentage
{
get { return widthPercentage; }
set { widthPercentage = value; }
}
public CustomGridColumn(PropertyDescriptor prop)
: base(prop)
{
}
object ICloneable.Clone()
{
return base.Clone();
}
}
[ListBindableAttribute(false)]
[Editor(typeof(GridBoundColumnsCollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
public class CustomGridColumnsCollection : GridBoundColumnsCollection, ICloneable
{
public CustomGridColumnsCollection(GridModelDataBinder table)
: base(table)
{
}
public override GridBoundColumn CreateBoundColumn(PropertyDescriptor pd)
{
return new CustomGridColumn(pd);
}
///
/// Creates a new CustomGridColumnsCollection and creates copies of all members in this collection.
///
/// A CustomGridColumnsCollection object.
public override object Clone()
{
GridModelDataBinder owner = null;
owner = this.Owner as GridModelDataBinder;
CustomGridColumnsCollection clone = new CustomGridColumnsCollection(owner);
foreach (GridBoundColumn item in this)
clone.Add((GridBoundColumn) item); //.Clone());
return clone;
}
///
/// Gets a specified CustomGridColumn in the CustomGridColumnsCollection.
///
///
/// Gets a specified CustomGridColumn in the CustomGridColumnsCollection.
///
public new CustomGridColumn this[int index]
{
get
{
return (CustomGridColumn) base[index];
}
}
///
/// Gets a specified CustomGridColumn in the CustomGridColumnsCollection.
///
public new CustomGridColumn this[string columnName]
{
get
{
return (CustomGridColumn) base[columnName];
}
}
///
/// Gets a specified CustomGridColumn in the CustomGridColumnsCollection.
///
public new CustomGridColumn this[PropertyDescriptor propDesc]
{
get
{
return (CustomGridColumn) base[propDesc];
}
}
}
public class SyncFusionBoundGrid : GridDataBoundGrid
{
///
/// Default constructor.
///
public SyncFusionBoundGrid() : base()
{
GridModelDataBinder.BoundColumnsCollectionType = typeof(CustomGridColumnsCollection);
}
///
/// A collection of grid bound columns. This property is overridden so
/// that the type used to define a grid bound column is a specialized
/// version.
///
[ Browsable(false), DesignerSerializationVisibilityAttribute( DesignerSerializationVisibility.Hidden ) ]
public override GridBoundColumnsCollection GridBoundColumns
{
get
{
return base.GridBoundColumns;
}
set
{
base.GridBoundColumns = value;
}
}
///
/// A collection of grid bound columns. This property is overridden so
/// that the type used to define a grid bound column is a specialized
/// version.
///
[ DesignerSerializationVisibilityAttribute( DesignerSerializationVisibility.Content ) ]
[ LocalizableAttribute(true) ]
[ Description( "Manages the columns to be displayed in the GridDataBoundGrid." ) ]
[ Category( "Data" ) ]
[ RefreshProperties( RefreshProperties.All ) ]
[ Editor( typeof(GridBoundColumnsCollectionEditor), typeof(UITypeEditor) ) ]
public CustomGridColumnsCollection CustomGridColumns
{
get
{
return base.GridBoundColumns as CustomGridColumnsCollection;
}
set
{
base.GridBoundColumns = value;
}
}
}
// Sets the style theme for scroll bars. Make sure the property �ThemesEnabled = true;�
this.gridDataBoundGrid1.GridOfficeScrollBars = OfficeScrollBars.Metro;
' Sets the style theme for scroll bars. Make sure the property �ThemesEnabled = true;�
e.gridDataBoundGrid1.GridOfficeScrollBars = OfficeScrollBars.Metro
// Enables the Office2007 scroll bars.
this.gridDataBoundGrid1.Office2007ScrollBars = true;
// Sets the color schemes for the Office2007 scroll bars.
this.gridDataBoundGrid1.Office2007ScrollBarsColorScheme = Office2007ColorScheme.Black;
' Enables the Office2007 scroll bars.
Me.gridDataBoundGrid1.Office2007ScrollBars = True
' Sets the color schemes for the Office2007 scroll bars.
Me.gridDataBoundGrid1.Office2007ScrollBarsColorScheme = Office2007ColorScheme.Black
GridFindReplaceDialogSink findReplaceDialogSink;
public GridFindReplaceDialogSink GridFindReplaceDialogSink
{
get
{
if (findReplaceDialogSink == null)
{
findReplaceDialogSink = new GridFindReplaceDialogSink(this);
}
return findReplaceDialogSink;
}
}
protected override void OnCurrentCellActivated(EventArgs e)
{
GridFindReplaceDialog.ResetFindLocation();
base.OnCurrentCellActivated(e);
}
protected override void OnControlGotFocus()
{
GridFindReplaceDialog.SetActiveSinkIfVisible(GridFindReplaceDialogSink);
base.OnControlGotFocus();
}
// to show the dialog:
GridFindReplaceDialog frDialog = GridFindReplaceDialog.Instance;
frDialog.SetState(grid.GridFindReplaceDialogSink, "", false);
frDialog.Show();
Dim findReplaceDialogSink As GridFindReplaceDialogSink
Public ReadOnly Property GridFindReplaceDialogSink() As GridFindReplaceDialogSink
Get
If findReplaceDialogSink Is Nothing Then
findReplaceDialogSink = New GridFindReplaceDialogSink(Me)
End If
Return findReplaceDialogSink
End Get
End Property
Protected Overrides Sub OnCurrentCellActivated(e As EventArgs)
GridFindReplaceDialog.ResetFindLocation()
MyBase.OnCurrentCellActivated(e)
End Sub 'OnCurrentCellActivated
Protected Overrides Sub OnControlGotFocus()
GridFindReplaceDialog.SetActiveSinkIfVisible(GridFindReplaceDialogSink)
MyBase.OnControlGotFocus()
End Sub 'OnEnter
' to show the dialog:
Dim frDialog As GridFindReplaceDialog = GridFindReplaceDialog.Instance
frDialog.SetState(grid.GridFindReplaceDialogSink, "", False)
frDialog.Show()
//suspend calculations...
GridFormulaCellModel formulaModel = this.gridControl1.CellModels["FormulaCell"] as GridFormulaCellModel;
formulaModel.CalculatingSuspended = true;
....
//make changes, say to, cells in the GridRangeInfo.Cells(1,1,10,20).
....
//later resume calculations and refresh any cells that depend on GridRangeInfo.Cells(1,1,10,20)
GridFormulaCellModel formulaModel = this.gridControl1.CellModels["FormulaCell"] as GridFormulaCellModel;
formulaModel.CalculatingSuspended = false;
formulaModel.RefreshRange(GridRangeInfo.Cells(1,1,10,20));
'suspend calculations...
Dim formulaModel As GridFormulaCellModel = Me.gridControl1.CellModel("FormulaCell")
formulaModel.CalculatingSuspended = True
....
'make changes, say to, cells in the GridRangeInfo.Cells(1,1,10,20).
....
'later resume calculations and refresh any cells that depend on GridRangeInfo.Cells(1,1,10,20)
Dim formulaModel As GridFormulaCellModel = Me.gridControl1.CellModel("FormulaCell")
formulaModel.CalculatingSuspended = False
formulaModel.RefreshRange(GridRangeInfo.Cells(1, 1, 10, 2))
public void DisplayAllAffectedCells()
{
GridFormulaEngine engine = ((GridFormulaCellModel)this.gridControl1.CellModels["FormulaCell"]).Engine;
foreach(object o in engine.DependentCells.Keys)
{
string s1 = o as string;
Console.Write(s1 + " affects ");
Hashtable ht = (Hashtable) engine.DependentCells[s1];
foreach(object o1 in ht.Keys)
{
string s2 = o1 as string;
Console.Write(s2 + " ");
}
Console.WriteLine(string.Empty);
}
}
Public Sub DisplayAllAffectedCells()
Dim engine As GridFormulaEngine = CType(Me.gridControl1.CellModels("FormulaCell"), GridFormulaCellModel).Engine
Dim o As Object
For Each o In engine.DependentCells.Keys
Dim s1 As String = CStr(o)
Console.Write((s1 + " affects "))
Dim ht As Hashtable = CType(engine.DependentCells(s1), Hashtable)
Dim o1 As Object
For Each o1 In ht.Keys
Dim s2 As String = CStr(o1)
Console.Write((s2 + " "))
Next o1
Console.WriteLine(string.Empty)
Next o
End Sub 'DisplayAllAffectedCells
public void DisplayAllFormulaDependencies()
{
GridFormulaEngine engine = ((GridFormulaCellModel)this.gridControl1.CellModels["FormulaCell"]).Engine;
foreach(object o in engine.DependentFormulaCells.Keys)
{
string s1 = o as string;
Console.Write(s1 + " depends upon ");
Hashtable ht = (Hashtable) engine.DependentFormulaCells[s1];
foreach(object o1 in ht.Keys)
{
string s2 = o1 as string;
Console.Write(s2 + " ");
}
Console.WriteLine(string.Empty);
}
}
Public Sub DisplayAllFormulaDependencies()
Dim engine As GridFormulaEngine = CType(Me.gridControl1.CellModels("FormulaCell"), GridFormulaCellModel).Engine
Dim o As Object
For Each o In engine.DependentFormulaCells.Keys
Dim s1 As String = CStr(o)
Console.Write((s1 + " depends upon "))
Dim ht As Hashtable = CType(engine.DependentFormulaCells(s1), Hashtable)
Dim o1 As Object
For Each o1 In ht.Keys
Dim s2 As String = CStr(o1)
Console.Write((s2 + " "))
Next o1
Console.WriteLine(string.Empty)
Next o
End Sub 'DisplayAllFormulaDependencies
// Sets the Copy, paste options of the formula cell in the grid.
GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
calculateEngine.FormulaCopyFlags = GridFormulaCopyFlags.ClipBoardFormula;
calculateEngine.FormulaCopyFlags = GridFormulaCopyFlags.NamedRangeReferencesUpdated;
' Sets the Copy, paste options of the formula cell in the grid.
Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
calculateEngine.FormulaCopyFlags = GridFormulaCopyFlags.ClipBoardFormula
calculateEngine.FormulaCopyFlags = GridFormulaCopyFlags.NamedRangeReferencesUpdated
//Register 3 grids so cell can be referenced across grids.
int sheetfamilyID = GridFormulaEngine.CreateSheetFamilyID();
GridFormulaEngine.RegisterGridAsSheet("summary", this.gridControl1.Model, sheetfamilyID);
GridFormulaEngine.RegisterGridAsSheet("income", this.gridControl2.Model, sheetfamilyID);
GridFormulaEngine.RegisterGridAsSheet("expenses", this.gridControl3.Model, sheetfamilyID);
....
//Sample formula usage for cells in gridControl1, the 'summary' grid.
//This code sums up some cells from gridControl3, the 'expenses' grid,
//and gridControl2, the 'income' grid.
//Sum the range B2:B8 from the expenses grid.
this.gridControl1[3,4].Text = "= Sum(expenses!B2:expenses!B8)";
//Sum the range B2:B4 from the income grid.
this.gridControl1[4,4].Text = "= Sum(income!B2:income!B4)";
'Register 3 grids so cells can be referenced across grids.
Dim sheetfamilyID As Integer = GridFormulaEngine.CreateSheetFamilyID();
GridFormulaEngine.RegisterGridAsSheet("summary", Me.gridControl1.Model, sheetfamilyID)
GridFormulaEngine.RegisterGridAsSheet("income", Me.gridControl2.Model, sheetfamilyID)
GridFormulaEngine.RegisterGridAsSheet("expenses", Me.gridControl3.Model, sheetfamilyID)
....
'Sample formula usage for cells in gridControl1, the 'summary' grid.
'This code sums ups some cells from gridControl3, the 'expenses' grid,
'and gridControl2, the 'income' grid.
'Sum the range B2:B8 from the expenses grid.
Me.gridControl1(3,4).Text = "= Sum(expenses!B2:expenses!B8)"
'Sum the range B2:B4 from the income grid.
Me.gridControl1(4,4).Text = "= Sum(income!B2:income!B4)"
//column 4 is formula col which used relative notation (row = 0)
//to enter the formulas as a simple string as the default value
//in the column
this.gridControl1.ColWidths[4] = 100;
this.gridControl1[0, 4].Text = "FormulaCell";
this.gridControl1.ColStyles[4].CellType = "FormulaCell";
this.gridControl1.ColStyles[4].Text = "= A0 + C0";
public string[] FormulaErrorStrings = new string[]
{
"binary operators cannot start an expression", //0
"cannot parse", //1
"bad library", //2
"invalid char in front of", //3
"number contains 2 decimal points", //4
"expression cannot end with an operator", //5
"invalid characters following an operator", //6
"invalid character in number", //7
"mismatched parentheses", //8
"unknown formula name", //9
"requires a single argument", //10
"requires 3 arguments", //11
"invalid Math argument", //12
"requires 2 arguments", //13
"bad index", //14
"too complex", //15
"circular reference: ", //16
"missing formula", //17
"improper formula", //18
"invalid expression", //19
"cell empty" //20
"bad formula", //21
"empty expression", //22
"Virtual Mode required - set UsesVirtualDataSource", //23
"mismatched string quotes", //24
"wrong number of arguments", //25
"invalid arguments", //26
"iterations do not converge", //27
"Control named '{0}' is already registered", //28
"Calculation overflow", //29
"missing operand" //30
"unknown sheet" //30
};
GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
// Parses the given string.
string parsedFormula = calculateEngine.Parse("=(29-7)+56");
Console.WriteLine("The parsed formula string is " + parsedFormula);
Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
' Parses the given string.
Dim parsedFormula As String = calculateEngine.Parse("=(29-7)+56")
// Adds the NamedRange to the NamedRange list.
GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
calculateEngine.NamedRanges.Add("A", 50);
calculateEngine.NamedRanges.Add("B", 25);
' Adds the NamedRange to the NamedRange list.
Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
calculateEngine.NamedRanges.Add("A", 50)
calculateEngine.NamedRanges.Add("B", 25)
// Removes the named range from the collection.
GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
calculateEngine.RemoveNamedRange("A");
' Removes the named range from the collection.
Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
calculateEngine.RemoveNamedRange("A")
public delegate string LibraryFunction(string args);
GridFormulaCellModel myModel = this.gridControl1.CellModels["FormulaCell"] as GridFormulaCellModel;
GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
// Add the custom-function to the library functions.
myModel.Engine.AddFunction("GetMaxNum", new GridFormulaEngine.LibraryFunction(myMaxNum));
// Custom function to be added to the library.
public string myMaxNum(string Args)
{
GridFormulaCellModel myModel = this.gridControl1.CellModels["FormulaCell"] as GridFormulaCellModel;
GridFormulaEngine engine = myModel.Engine;
// Perform the required operations.
int a, b, c;
string[] coll = Args.Split(new char[] { ',' });
a = Convert.ToInt32(coll[0]);
b = Convert.ToInt32(coll[1]);
c = Convert.ToInt32(coll[2]);
int big = (a > b ? a : b);
int bigger = (big > c ? big : c);
// Make sure to define the custom function with string return type.
return bigger.ToString();
}
Dim myModel As GridFormulaCellModel = TryCast(Me.gridControl1.CellModels("FormulaCell"), GridFormulaCellModel)
Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
' Add the custom-function to the library functions.
myModel.Engine.AddFunction("GetMaxNum", New GridFormulaEngine.LibraryFunction(myMaxNum))
' Custom function to be added to the library.
Public Function myMaxNum(ByVal Args As String) As String
Dim myModel As GridFormulaCellModel = TryCast(Me.gridControl1.CellModels("FormulaCell"), GridFormulaCellModel)
Dim engine As GridFormulaEngine = myModel.Engine
' Perform the required operations.
Dim a, b, c As Integer
Dim coll() As String = Args.Split(New Char() { ","c })
a = Convert.ToInt32(coll(0))
b = Convert.ToInt32(coll(1))
c = Convert.ToInt32(coll(2))
Dim big As Integer = (If(a > b, a, b))
Dim bigger As Integer = (If(big > c, big, c))
' Make sure to define the custom function with string return type.
Return bigger.ToString()
End Function
// Removes the function from the library.
GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
calculateEngine.RemoveFunction("Sum");
' Removes the function from the library.
Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
calculateEngine.RemoveFunction("Sum")
GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
string myFormula = "(7+6)*2";
// Parses the given string.
string parsedValue = calculateEngine.Parse(myFormula);
// Computes the resultant value.
string computedValue = calculateEngine.ComputeFormulaText(parsedValue);
Console.WriteLine("The computed value is " + computedValue);
Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
Dim myFormula As String = "(7+6)*2"
' Parses the given string
Dim parsedValue As String = calculateEngine.Parse(myFormula)
' Computes the resultant value.
Dim computedValue As String = calculateEngine.ComputeFormulaText(parsedValue)
GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
double[] arr = { 4, 7, 9, 14, 23, 56 }; double q = 1;
// Computes the mean value of given numbers.
this.gridControl1[5, 5].CellValue = calculateEngine.Mean(arr);
Console.WriteLine("The mean of array values are " + this.gridControl1[5, 5].CellValue);
Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
Dim arr() As Double = { 4, 7, 9, 14, 23, 56 }
Dim q As Double = 1
' Computes the mean value of given numbers.
Me.gridControl1(5, 5).CellValue = calculateEngine.Mean(arr)
Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
Dim arr() As Double = { 4, 7, 9, 14, 23, 56 }
' Computes the mean value of given numbers.
Me.gridControl1(5, 5).CellValue = calculateEngine.Mean(arr,1,2)
void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
{
// Gets the cell value from the given row index and column index.
GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
string cellValue = calculateEngine.GetValueFromGrid(e.RowIndex, e.ColIndex);
Console.WriteLine("The Cell value is " + cellValue);
}
Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
' Gets the cell value from the given row index and column index.
Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
Dim cellValue As String = calculateEngine.GetValueFromGrid(e.RowIndex, e.ColIndex)
End Sub
// Gets the cell value from a particular cell index.
GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
string cellValue = calculateEngine.GetValueFromGrid("C33");
Console.WriteLine("The cell value is " + cellValue);
' Gets the cell value from a particular cell index.
Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
Dim cellValue As String = calculateEngine.GetValueFromGrid("C33")
public string ComputeSumPosNums(string args)
{
GridFormulaEngine engine = GridFormulaEngine.FunctionEngineContext;
string sum = string.Empty;
foreach(string r in args.Split(new char[]{','}))
{
if(r.IndexOf(':') > -1) //is a cellrange
{
foreach(string s in engine.GetCellsFromArgs(r))
{
s1 = engine.GetValueFromArg(s).Replace("'",string.Empty);
//... do some calculations to compute sum
}
}
}
return sum.ToString();
}
Public Function ComputeSumPosNums(args As String) As String
Dim engine As GridFormulaEngine = GridFormulaEngine.FunctionEngineContext
Dim sum As String = string.Empty
Dim r As String
For Each r In args.Split(New Char() {","c})
If r.IndexOf(":"c) > - 1 Then 'is a cellrange
Dim s As String
For Each s In engine.GetCellsFromArgs(r)
s1 = engine.GetValueFromArg(s).Replace("'", string.Empty)
'... do some calculations to compute sum
Next s
End If
Next r
Return sum.ToString()
End Function 'ComputeSumPosNums
//subscribe to the event before any formulas are loaded into the grid...
this.engine = ((GridFormulaCellModel)gridControl1.CellModels["FormulaCell"]).Engine;
this.engine.FormulaParsing += new GridFormulaParsingEventHandler(engine_FormulaParsing);
//Here is the handler code that adds an = if necessary so any string beginning with +, - or =
//is treated as a formula.
void engine_FormulaParsing(object sender, GridFormulaParsingEventArgs e)
{
//allow cells starting with + and - to be treated as formula cells.
if (e.Text.StartsWith("-"))
e.Text = "=" + e.Text;
else if (e.Text.StartsWith("+"))
e.Text = "=" + e.Text.Substring(1);
}
// Initializes the image list to be displayed in the grid.
ImageList img = new ImageList();
// Adds the image to the list.
img.Images.Add(new Bitmap(FindImageFile(@"\...\...\...\FileName.jpg")));
// Assigns the image-list to the grid.
this.gridListControl1.ImageList = img;
' Initializes the image list to be displayed in the grid.
Dim img As New ImageList()
' Adds the image to the list.
img.Images.Add(New Bitmap(FindImageFile("\...\...\...\FileName.jpg")))
' Assigns the image-list to the grid.
Me.gridListControl1.ImageList = img
void Grid_CellClick(object sender, GridCellClickEventArgs e)
{
// Gets the style properties of a given column index and assigns to other GridStyleInfo instance.
GridStyleInfo myStyle = this.gridListControl1.GetColumnStyle(e.ColIndex);
}
Private Sub Grid_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
' Gets the style properties of a given column index and assigns to other GridStyleInfo instance.
Dim myStyle As GridStyleInfo = Me.gridListControl1.GetColumnStyle(e.ColIndex)
End Sub
// Creates a new column in the grid.
PropertyDescriptor propertyDesc = this.gridListControl1.GetColumnStyle(2).Tag as PropertyDescriptor;
this.gridListControl1.CreateGridColumn(propertyDesc, 4);
' Creates a new column in the grid.
Dim propertyDesc As PropertyDescriptor = TryCast(Me.gridListControl1.GetColumnStyle(2).Tag, PropertyDescriptor)
Me.gridListControl1.CreateGridColumn(propertyDesc, 4)
// Finds the specified string in the grid and returns it's index value.
// If the string case should be ignored, then the last parameter should be "true"
int foundedItem=this.gridListControl1.FindItem("o", true, 1, true);
Console.WriteLine("The item is found in the index " + foundedItem);
' Finds the specified string in the grid and returns it's index value.
' If the string case should be ignored, then the last parameter should be "true"
Dim foundedItem As Integer=Me.gridListControl1.FindItem("o", True, 1, True)
// Sets the border style of the grid.
this.gridListControl1.BorderStyle = BorderStyle.FixedSingle;
' Sets the border style of the grid.
Me.gridListControl1.BorderStyle = BorderStyle.FixedSingle
// Clears the selection done in the grid.
this.gridListControl1.ClearSelected();
' Clears the selection done in the grid.
Me.gridListControl1.ClearSelected()
// Finds the specified string in the grid and returns it's index value.
// The string is considered as case-insensitive.
int foundedItem = this.gridListControl1.FindString("Texas");
Console.WriteLine("The specified string is found in the index " + foundedItem);
' Finds the specified string in the grid and returns it's index value.
' The string is considered as case-insensitive.
Dim foundedItem As Integer = Me.gridListControl1.FindString("Texas")
// Finds the specified string in the grid from a specific index to start the search and returns it's index value.
// The string is considered as case-insensitive.
int foundedItem = this.gridListControl1.FindString("Texas", 5);
Console.WriteLine("The specified string is found in the index " + foundedItem);
' Finds the specified string in the grid from a specific index to start the search and returns it's index value.
' The string is considered as case-insensitive.
Dim foundedItem As Integer = Me.gridListControl1.FindString("Texas", 5)
void Grid_CellClick(object sender, GridCellClickEventArgs e)
{
int rowHeight = this.gridListControl1.GetItemHeight(e.RowIndex);
Console.WriteLine("The row height is " + rowHeight);
}
Private Sub Grid_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
Dim rowHeight As Integer = Me.gridListControl1.GetItemHeight(e.RowIndex)
End Sub
// Sets the specified column to display images in the grid. Here "2" is the Column index.
this.gridListControl1.ImageColumn = 2;
' Sets the specified column to display images in the grid. Here "2" is the Column index.
Me.gridListControl1.ImageColumn = 2
// Sets the data source to the grid.
DataTable dataTable = new DataTable();
this.gridListControl1.DataSource = dataTable;
// Gets the row count of the associated data source to the grid.
int rowcount = this.gridListControl1.GetRowCount(dataTable);
Console.WriteLine("Row count of the associated data source is " + rowcount);
' Sets the data source to the grid.
Dim dataTable As New DataTable()
Me.gridListControl1.DataSource = dataTable
' Gets the row count of the associated data source to the grid.
Dim rowcount As Integer = Me.gridListControl1.GetRowCount(dataTable)
// Sets the selection mode to the grid.
this.gridListControl1.SelectionMode = SelectionMode.MultiExtended;
' Sets the selection mode to the grid.
Me.gridListControl1.SelectionMode = SelectionMode.MultiExtended
// Sets the specific index of the grid to be in the selected state.
this.gridListControl1.SetSelected(5, true);
' Sets the specific index of the grid to be in the selected state.
Me.gridListControl1.SetSelected(5, True)
// Sets the row height of the grid.
this.gridListControl1.ItemHeight = 30;
' Sets the row height of the grid.
Me.gridListControl1.ItemHeight = 30
// Apply the visual styles to the grid.
// Make sure to set the "ThemesEnabled = true;
this.gridListControl1.GridVisualStyles = GridVisualStyles.Metro;
' Apply the visual styles to the grid.
' Make sure to set the "ThemesEnabled = true;
Me.gridListControl1.GridVisualStyles = GridVisualStyles.Metro
// Sets the color styles of the grid. This property doesn't depends on "ThemesEnabled" property.
this.gridListControl1.ColorStyles = ColorStyles.Office2010Silver;
' Sets the color styles of the grid. This property doesn't depends on "ThemesEnabled" property.
Me.gridListControl1.ColorStyles = ColorStyles.Office2010Silver
// Sets the back-color for headers.
this.gridListControl1.HeaderBackColor = Color.Red;
' Sets the back-color for headers.
Me.gridListControl1.HeaderBackColor = Color.Red
// Sets the text color of the grid.
this.gridListControl1.HeaderTextColor = Color.White;
' Sets the text color of the grid.
Me.gridListControl1.HeaderTextColor = Color.White
// Sets the alpha blend selection color
this.gridListControl1.AlphaBlendSelectionColor = Color.Red;
' Sets the alpha blend selection color
Me.gridListControl1.AlphaBlendSelectionColor = Color.Red
public class GroupDropAreaDragHeaderMouseController : GroupDragHeaderMouseControllerBase
{
public GroupDropAreaDragHeaderMouseController(GridGroupDropArea grid)
{
this.groupDropArea = grid;
isGroupAreaOrigin = true;
clickCellsController = new GridClickCellsMouseController(grid);
}
internal GridClickCellsMouseController clickCellsController;
int clickCellsControllerHitTest = 0;
public GridClickCellsMouseController ClickCellsController
{
get
{
return clickCellsController;
}
}
public void ResetClickCellsController()
{
if (this.entered)
clickCellsController.MouseHoverLeave(EventArgs.Empty);
else if (clickCellsControllerHitTest != 0)
clickCellsController.CancelMode();
entered = false;
clickCellsControllerHitTest = 0;
}
// unrelated code left out here ...
#region IMouseController implementation
public virtual string Name
{
get
{
return "DragGroupHeader";
}
}
public virtual Cursor Cursor
{
get
{
if (cursor != null)
return cursor;
return clickCellsController.Cursor;
}
}
bool entered = false;
public virtual void MouseHoverEnter()
{
if (clickCellsControllerHitTest != 0)
{
entered = true;
clickCellsController.MouseHoverEnter();
}
}
public virtual void MouseHover(MouseEventArgs e)
{
if (clickCellsControllerHitTest != 0)
clickCellsController.MouseHover(e);
}
public virtual void MouseHoverLeave(EventArgs e)
{
if (entered)
{
clickCellsController.MouseHoverLeave(e);
entered = false;
}
}
public virtual void MouseDown(MouseEventArgs e)
{
if (clickCellsControllerHitTest != 0)
clickCellsController.MouseDown(e);
}
public virtual void MouseMove(MouseEventArgs e)
{
if (clickCellsControllerHitTest != 0)
clickCellsController.MouseMove(e);
}
public virtual void MouseUp(MouseEventArgs e)
{
if (clickCellsControllerHitTest != 0)
clickCellsController.MouseUp(e);
}
public virtual void CancelMode()
{
if (clickCellsControllerHitTest != 0)
clickCellsController.CancelMode();
}
public virtual int HitTest(MouseEventArgs e, IMouseController controller)
{
clickCellsControllerHitTest = clickCellsController.HitTest(e, controller);
return clickCellsControllerHitTest;
}
#endregion
}
GridPrintDocument pd = new GridPrintDocument(grid); //Assumes the default printer
if (PrinterSettings.storedPageSettings != null)
{
pd.DefaultPageSettings = PrinterSettings.storedPageSettings ;
}
PrintDialog dlg = new PrintDialog() ;
dlg.Document = pd;
dlg.AllowSelection = true;
dlg.AllowSomePages = true;
DialogResult result = dlg.ShowDialog();
if (result == DialogResult.OK)
{
pd.Print();
}
Use the following code for print preview:
GridControlBase grid = ActiveGrid;
GridPrintDocument pd = new GridPrintDocument(grid, true); //Assumes the default printer
if (PrinterSettings.storedPageSettings != null)
{
pd.DefaultPageSettings = PrinterSettings.storedPageSettings ;
}
PrintPreviewDialog dlg = new PrintPreviewDialog() ;
dlg.Document = pd;
dlg.ShowDialog();
// Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
ExpressionFieldEvaluator expression = new ExpressionFieldEvaluator(this.gridControl1.Model);
int call = expression.MaximumRecursiveCalls = 5;
Console.WriteLine("The maximum recursive calls allowed is " + call);
' Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
Dim expression As New ExpressionFieldEvaluator(Me.gridControl1.Model)
Dim[call] As Integer = expression.MaximumRecursiveCalls = 5
public string[] FormulaErrorStrings = new string[]
{
"binary operators cannot start an expression", //0
"cannot parse", //1
"bad library", //2
"invalid char in front of", //3
"number contains 2 decimal points", //4
"expression cannot end with an operator", //5
"invalid characters following an operator", //6
"invalid character in number", //7
"mismatched parentheses", //8
"unknown formula name", //9
"requires a single argument", //10
"requires 3 arguments", //11
"invalid Math argument", //12
"requires 2 arguments", //13
"bad index", //14
"too complex", //15
"circular reference: ", //16
"missing formula", //17
"improper formula", //18
"invalid expression", //19
"cell empty", //20
"empty expression", //21
"mismatched string tics", //22
"named functions not supported in expressions", //23
"not a formula", //24
"missing operand" //25
};
void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
{
// Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
ExpressionFieldEvaluator expression = new ExpressionFieldEvaluator(this.gridControl1.Model);
// The expression to be parsed.
string expressionName = "=((8+6)*(2))";
// The parsed value of the expression.
string parsedValue = expression.Parse(expressionName);
// The resultant value.
string computedValue = expression.ComputeFormulaValueAt(parsedValue, e.RowIndex, e.ColIndex, expressionName);
Console.WriteLine("The parsed string from the given string is " + computedValue);
}
Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
' Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
Dim expression As New ExpressionFieldEvaluator(Me.gridControl1.Model)
' The expression to be parsed.
Dim expressionName As String = "=((8+6)*(2))"
' The parsed value of the expression.
Dim parsedValue As String = expression.Parse(expressionName)
' The resultant value.
Dim computedValue As String = expression.ComputeFormulaValueAt(parsedValue, e.RowIndex, e.ColIndex, expressionName)
End Sub
// Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
ExpressionFieldEvaluator expression = new ExpressionFieldEvaluator(this.gridControl1.Model);
Parses the given valid string.
string parsedString = expression.Parse("=((8+6)*(2))");
Console.WriteLine("The parsed string from the given string is " + parsedString);
// Computes the parsed given string into the required result.
parsedString = expression.ComputeFormulaValueAt(parsedString);
Console.WriteLine("The parsed string from the given string is " + parsedString);
' Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
Dim expression As New ExpressionFieldEvaluator(Me.gridControl1.Model)
' Parses the given valid string.
Dim parsedString As String = expression.Parse("=((8+6)*(2))")
' Computes the parsed given string into the required result.
parsedString = expression.ComputeFormulaValueAt(parsedString)
void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
{
// Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
ExpressionFieldEvaluator expression = new ExpressionFieldEvaluator(this.gridControl1.Model);
this.gridControl1[e.RowIndex, e.ColIndex].CellValue = "=((8+6)*(2))";
// Parses the given string at the specified cell index.
string parsedFormula = expression.Parse(this.gridControl1[e.RowIndex, e.ColIndex].CellValue.ToString());
// Computes the parsed given string into the required result.
string parsedString = expression.ComputeFormulaValueAt(parsedFormula,e.RowIndex, e.ColIndex);
Console.WriteLine("The parsed string from the given string is " + parsedString);
}
Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
' Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
Dim expression As New ExpressionFieldEvaluator(Me.gridControl1.Model)
Me.gridControl1(e.RowIndex, e.ColIndex).CellValue = "=((8+6)*(2))"
' Parses the given string at the specified cell index.
Dim parsedFormula As String = expression.Parse(Me.gridControl1(e.RowIndex, e.ColIndex).CellValue.ToString())
' Computes the parsed given string into the required result.
Dim parsedString As String = expression.ComputeFormulaValueAt(parsedFormula,e.RowIndex, e.ColIndex)
End Sub
// Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
ExpressionFieldEvaluator expression = new ExpressionFieldEvaluator(this.gridControl1.Model);
// Parses the given valid string.
string parsedString = expression.Parse("=((8+6)*(2))");
Console.WriteLine("The parsed string from the given string is " + parsedString);
' Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
Dim expression As New ExpressionFieldEvaluator(Me.gridControl1.Model)
' Parses the given valid string.
Dim parsedString As String = expression.Parse("=((8+6)*(2))")
// step 1 - register the function name and delegate
ExpressionFieldEvaluator evaluator = this.groupingEngine.TableDescriptor.ExpressionFieldEvaluator;//.CreateExpressionFieldEvaluator(this.groupingEngine.TableDescriptor);
evaluator.AddFunction("Func", new ExpressionFieldEvaluator.LibraryFunction(ComputeFunc));
//. . .
// step 1 - defining the method
// Computes the absolute value of arg1-2*arg2
// parameter s- a list of 2 arguments
// returns string holding computed value
public string ComputeFunc(string s)
{
//get the list delimiter (for en-us, its is a comma)
char comma = Convert.ToChar(this.gridGroupingControl1.Culture.TextInfo.ListSeparator);
string[] ss = s.Split(comma);
if(ss.GetLength(0) != 2)
throw new ArgumentException("Requires 2 arguments.");
double arg1, arg2;
if(double.TryParse(ss[0], System.Globalization.NumberStyles.Any, null, out arg1)
&& double.TryParse(ss[1], System.Globalization.NumberStyles.Any, null, out arg2))
{
return Math.Abs(arg1 - 2 * arg2).ToString();
}
return "";
}
' step 1 - register the function name and delegate
Dim evaluator As ExpressionFieldEvaluator = Me.groupingEngine.TableDescriptor.ExpressionFieldEvaluator
evaluator.AddFunction("Func", New ExpressionFieldEvaluator.LibraryFunction(AddressOf ComputeFunc))
'. . .
' step 1 - defining the method
' Computes the absolute value of arg1-2*arg2
' parameter s- a list of 2 arguments
' returns string holding computed value
Public Function ComputeFunc(s As String) As String
'get the list delimiter (for en-us, its is a comma)
Dim comma As Char = Convert.ToChar(Me.gridGroupingControl1.Culture.TextInfo.ListSeparator)
Dim ss As String() = s.Split(comma)
If ss.GetLength(0) <> 2 Then
Throw New ArgumentException("Requires 2 arguments.")
End If
Dim arg1, arg2 As Double
If Double.TryParse(ss(0), System.Globalization.NumberStyles.Any, Nothing, arg1) _
AndAlso Double.TryParse(ss(1), System.Globalization.NumberStyles.Any, Nothing, arg2) Then
Return Math.Abs((arg1 - 2 * arg2)).ToString()
End If
Return ""
End Function 'ComputeFunc
// Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
ExpressionFieldEvaluator expression = new ExpressionFieldEvaluator(this.gridControl1.Model);
// Removes the function from the library.
expression.RemoveFunction("Add");
' Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
Dim expression As New ExpressionFieldEvaluator(Me.gridControl1.Model)
' Removes the function from the library.
expression.RemoveFunction("Add")
protected override void OnDrawCellDisplayText(GridDrawCellDisplayTextEventArgs e)
{
base.OnDrawCellDisplayText (e);
GridGdiPaint.AllowTextOut = false;
if (!e.Cancel)
e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style);
}
protected override void OnFillRectangleHook(GridFillRectangleHookEventArgs e)
{
base.OnFillRectangleHook (e);
if (!e.Cancel)
e.Cancel = GridGdiPaint.Instance.FillRectangle(e.Graphics, e.Bounds, e.Brush);
}
- Or -
public class PerformanceGridControl : GridControl
{
private bool useGDI;
///
/// Property UseGDI (bool)
///
public bool UseGDI
{
get
{
return this.useGDI;
}
set
{
if (this.UseGDI != value)
{
this.useGDI = value;
Invalidate();
}
}
}
private bool useDoubleBuffer = true;
public bool UseDoubleBuffer
{
get
{
return this.useDoubleBuffer;
}
set
{
if (this.useDoubleBuffer != value)
{
this.useDoubleBuffer = value;
SetStyle(ControlStyles.Opaque, value);
SetStyle(ControlStyles.DoubleBuffer, value);
}
}
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
if (useDoubleBuffer)
base.OnPaintBackground (pevent);
}
protected override void OnDrawCellDisplayText(GridDrawCellDisplayTextEventArgs e)
{
base.OnDrawCellDisplayText (e);
if (!useGDI || e.Cancel)
return;
e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style);
}
protected override void OnFillRectangleHook(GridFillRectangleHookEventArgs e)
{
base.OnFillRectangleHook (e);
if (!useGDI || e.Cancel)
return;
e.Cancel = GridGdiPaint.Instance.FillRectangle(e.Graphics, e.Bounds, e.Brush);
}
}
protected override void OnDrawCellDisplayText(GridDrawCellDisplayTextEventArgs e)
{
base.OnDrawCellDisplayText (e);
GridGdiPaint.AllowTextOut = false;
if (!e.Cancel)
e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style, e.Bounds);
}
protected override void OnFillRectangleHook(GridFillRectangleHookEventArgs e)
{
base.OnFillRectangleHook (e);
if (!e.Cancel)
e.Cancel = GridGdiPaint.Instance.FillRectangle(e.Graphics, e.Bounds, e.Brush);
}
protected override void OnDrawCellDisplayText(GridDrawCellDisplayTextEventArgs e)
{
base.OnDrawCellDisplayText (e);
GridGdiPaint.AllowTextOut = false;
if (!e.Cancel)
{
GridControlBase grid = (GridControlBase) sender;
Rectangle clipBounds = grid.ViewLayout.RangeInfoToRectangle(GridRangeInfo.Cell(e.Style.CellIdentity.RowIndex, e.Style.CellIdentity.ColIndex), GridCellSizeKind.VisibleSize);
e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style, e.Bounds, clipBounds);
}
}
protected override void OnFillRectangleHook(GridFillRectangleHookEventArgs e)
{
base.OnFillRectangleHook (e);
if (!e.Cancel)
e.Cancel = GridGdiPaint.Instance.FillRectangle(e.Graphics, e.Bounds, e.Brush);
}
protected override void OnDrawCellDisplayText(GridDrawCellDisplayTextEventArgs e)
{
base.OnDrawCellDisplayText (e);
GridGdiPaint.AllowTextOut = false;
if (!e.Cancel)
{
GridControlBase grid = (GridControlBase) sender;
Rectangle clipBounds = grid.ViewLayout.RangeInfoToRectangle(GridRangeInfo.Cell(e.Style.CellIdentity.RowIndex, e.Style.CellIdentity.ColIndex), GridCellSizeKind.VisibleSize);
e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style, e.Bounds, clipBounds);
}
}
protected override void OnFillRectangleHook(GridFillRectangleHookEventArgs e)
{
base.OnFillRectangleHook (e);
if (!e.Cancel)
e.Cancel = GridGdiPaint.Instance.FillRectangle(e.Graphics, e.Bounds, e.Brush);
}
protected override void OnDrawCellDisplayText(GridDrawCellDisplayTextEventArgs e)
{
base.OnDrawCellDisplayText (e);
GridGdiPaint.AllowTextOut = false;
if (!e.Cancel)
e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style);
}
protected override void OnFillRectangleHook(GridFillRectangleHookEventArgs e)
{
base.OnFillRectangleHook (e);
if (!e.Cancel)
e.Cancel = GridGdiPaint.Instance.FillRectangle(e.Graphics, e.Bounds, e.Brush);
}