IN THIS TASK
On this page
SUMMARY
You can use this step-by-step guide with Visual C# .NET to handle events for an Office XP Spreadsheet component on a Windows Form.
back to the top
back to the top
Step-by-Step Guide
Before you start the following steps, you must modify the class wrappers that Visual Studio .NET generates for the Office XP Web Components (OWC). You must modify the class wrappers for Visual Basic .NET to properly handle OWC events. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:328275 How To Handle Events for the Office Web Components in Visual Studio .NET
1. | Create a new Visual C# .NET Windows Application project. Name the project SheetEvents.
Form1 creates, and then opens in Design view. |
2. | On the View menu, click Toolbox. |
3. | Drag the Spreadsheet component from the Toolbox to Form1. |
4. | On the View menu, click Code. |
5. | Add the following lines of code before the NAMESPACE statement in the Form1.cs file:
|
6. | Add the following code to the EndEdit, BeforeContextMenu, and CommandExecute events:
|
7. | Press F5 to build and to run the sample. |
8. | Enter a value in cell A1.
If the value is not a number between zero and 100, you receive a message, and then the edit cancels. |
9. | Right-click any cell to display the shortcut menu, and then click any of the commands on the menu so you can see the results. |