officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-table-dot-foreachcell-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-tablecellprocessordelegate-x29.md
Performs the specified action on each cell in the table.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
void ForEachCell(
TableCellProcessorDelegate cellProcessor
)
Sub ForEachCell(
cellProcessor As TableCellProcessorDelegate
)
| Name | Type | Description |
|---|---|---|
| cellProcessor | TableCellProcessorDelegate |
The TableCellProcessorDelegate delegate to perform on each cell in a table.
|
The TableCellProcessorDelegate is a delegate to a method that performs an action on the cell passed to it. Each cell is individually passed to the TableCellProcessorDelegate.
Tip
You can also use anonymous methods as delegates.
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
void IterateCells(Table _table) {
_table.BeginUpdate();
_table.ForEachCell(new TableCellProcessorDelegate(MakeMultiplicationCell));
_table.EndUpdate();
}
void MakeMultiplicationCell(TableCell cell, int i, int j)
{
richEditControl1.Document.InsertText(cell.Range.Start,
String.Format("{0}*{1} = {2}", i+2, j+2, (i+2) * (j+2)));
}
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
Private Sub IterateCells(ByVal _table As Table)
_table.BeginUpdate()
_table.ForEachCell(New TableCellProcessorDelegate(AddressOf MakeMultiplicationCell))
_table.EndUpdate()
End Sub
Private Sub MakeMultiplicationCell(ByVal cell As TableCell, ByVal i As Integer, ByVal j As Integer)
richEditControl1.Document.InsertText(cell.Range.Start, String.Format("{0}*{1} = {2}", i+2, j+2, (i+2) * (j+2)))
End Sub
The following code snippets (auto-collected from DevExpress Examples) contain references to the ForEachCell(TableCellProcessorDelegate) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Table.cs#L80
//Change cell background color.
table.ForEachCell(new TableCellProcessorDelegate(TableHelper.ChangeCellColor));
table.ForEachCell(new TableCellProcessorDelegate(TableHelper.ChangeCellBorderColor));
wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/TableActions.cs#L181
//Change cell background color.
table.ForEachCell(new TableCellProcessorDelegate(TableHelper.ChangeCellColor));
table.ForEachCell(new TableCellProcessorDelegate(TableHelper.ChangeCellBorderColor));
word-document-api-examples/CS/CodeExamples/TablesActions.cs#L128
// Change the cell borders and background color.
table.ForEachCell((cell, i, j) =>
{
winforms-richedit-customize-popup-menu/CS/RichEditContextMenu/Form1.cs#L25
table.BeginUpdate();
table.ForEachCell(delegate (TableCell cell, int rowIndex, int cellIndex) {
richEditControl.Document.InsertText(cell.Range.Start, string.Format("{0}:{1}", rowIndex, cellIndex));
wpf-rich-text-editor-customize-context-menu/CS/ContextMenuCustomization/MainWindow.xaml.cs#L18
table.BeginUpdate();
table.ForEachCell(delegate (TableCell cell, int rowIndex, int cellIndex) {
richEdit.Document.InsertText(cell.Range.Start, string.Format("{0}:{1}", rowIndex, cellIndex));
winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Table.vb#L70
'Change cell background color.
table.ForEachCell(New DevExpress.XtraRichEdit.API.Native.TableCellProcessorDelegate(AddressOf RichEditAPISample.CodeExamples.TableActions.TableHelper.ChangeCellColor))
table.ForEachCell(New DevExpress.XtraRichEdit.API.Native.TableCellProcessorDelegate(AddressOf RichEditAPISample.CodeExamples.TableActions.TableHelper.ChangeCellBorderColor))
wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/TableActions.vb#L162
'Change cell background color.
table.ForEachCell(New TableCellProcessorDelegate(AddressOf TableHelper.ChangeCellColor))
table.ForEachCell(New TableCellProcessorDelegate(AddressOf TableHelper.ChangeCellBorderColor))
word-document-api-examples/VB/CodeExamples/TablesActions.vb#L118
' Change the cell borders and background color.
table.ForEachCell(
Sub(cell As TableCell, i As Integer, j As Integer)
winforms-richedit-customize-popup-menu/VB/RichEditContextMenu/Form1.vb#L24
table.BeginUpdate()
table.ForEachCell(Sub(cell As TableCell, rowIndex As Integer, cellIndex As Integer) richEditControl.Document.InsertText(cell.Range.Start, String.Format("{0}:{1}", rowIndex, cellIndex)))
table.EndUpdate()
word-document-api-invoke-print-preview-dialog/VB/Form1.vb#L41
_table.TableAlignment = TableRowAlignment.Center
_table.ForEachCell(Sub(cell, rowIndex, columnIndex) richServer.Document.InsertText(cell.Range.Start, String.Format("{0}*{1} is {2}", rowIndex + 2, columnIndex + 2, (rowIndex + 2) * (columnIndex + 2))))
_table.EndUpdate()
See Also