Microsoft Office Tutorials and References
In Depth Information
The worksheet host item
The worksheet host item
A worksheet host item is the worksheet in the Excel workbook. You can have more
than one worksheet in your workbook. This is an object that exposes events and
works as a holder for components. You can add Windows forms controls to the host
item, just as you would add them to your Windows forms. Worksheets are the key
components of any kind of Excel solution.
The following example will show how to program for the Change event of the cells
in the Excel worksheet. Open Visual Studio 2008 and create a new solution, as before.
Write the following code inside the ThisWorkbook.cs file. This will register the
Change event in the worksheet host item's .cs file:
// Visual studio generated InternalStartup()
private void InternalStartup()
// Register your Change event
this.Change += new Microsoft.Office.Interop.Excel.
The following code should be placed inside the Change event of the worksheet
host item:
private void Sheet1_Change(Excel.Range AuthorCellPoint)
// Reading the current context of cell which has been changed
string AuthorCellChanged = AuthorCellPoint.
get_Address(missing, missing,Excel.XlReferenceStyle.xlA1,
missing, missing);
// Message displaying the changed cell address
MessageBox.Show("The Cell " + this.Name + " : " +
AuthorCellChanged + " is changed.");
Search JabSto ::

Custom Search