This sample shows the implementation of the ICalcData on a data grid object whose Datasource property is a data table. The class CalcDataGrid derives the data grid and implements the ICalcData.
Features:
The following image illustrates a form with a single instance of the CalcDataGrid being populated with data.
A CalcDataGrid tweaked to display any underlying formulae is illustrated below. Notice that in column B, changing the first cell affects all the other cells in that column.
The ICalcData interface has only three methods and one event.
The implementation uses both the ListChanged event and the ColumnChanged event on the data source and raises the ValueChanged event at the appropriate point.
The WireParentObject is used to subscribe to these events. This is a typical use of the WireParentObject method. It gives the ICalcData object the opportunity to subscribe to the events that are necessary to monitor the changes in the object.
This sample also shows that it is possible to have multiple Windows Forms data grids in a table control to support a workbook-type application. You can even reference cells on different grids in a formula.
Multiple CalcDataGrids in a tab control are illustrated in the image below: