![]() |
Visio 2003 Developer's Survival Pack Tools and Samples |
Chapter 26: Visio Drawing Control (.NET, C#) | |
![]() ![]() |
The purpose of this sample is illustrate some basic operations using the Visio Drawing Control on a .NET Form in C#.
This sample obviously requires Visual Studio .NET. I used VS.NET 7.1, with .NET Framework 1.1.
In addition, the example uses COM Interop with Visio and the control, and thus relies upon the Visio Primary Interop Adapters (PIAs) for Visio and the control. These would normally be installed as a side-effect of installing the main Visio product without any special additional actions.
File | Description |
Generic_DotNET.sln | Solution object for this chapter. Double-click on this file to start Visual Studio .NET and load the solution and its one project, Generic_DotNet. |
Form1.cs | The main form on which is located an instance of the Visio Drawing Control, and some other features. |
Many other files | As you are no doubt aware, a VS.NET project involves quite a few miscellaneous files |
Generic_DotNET\bin\Debug\ Generic_DotNET.exe |
The actual executable resulting from the project. |
Generic_DotNET\bin\Debug\ MyStartDoc.vdx |
A startup doc which the example program loads. This should be in the same directory as the project's exe file. |
You can run the application either from within the VS.NET IDE, or by launching the exe from Windows Explorer.
Try the following exercises.
Exercise | Description |
File > New | Reloads startup document. That document can act to initialize various display and drawing characteristics |
File > Clear Doc | Deletes all existing shapes on the control's drawing |
File > Open... | Loads an existing Visio file into the drawing control |
File > Save, Save As | Saves drawing control's contents to a file |
Open Basic Shapes button | Opens the Basic Shapes stencil |
Tidy Windows button | Gets rid of unwanted windows, for example the Shape Search area |
Random Colors button | Drag some shapes onto the page, then hit the Random Colors button to fill the shapes with random colors. |
Track Mouse checkbox | If you check this box, then the app will watch Mouse Move events. If the mouse moves over a shape, the app will color it red. |
Watch Drop button | Causes app to listen for Shape Added events. Reports name of shape dropped to a label beside the button. |
Article Created: 2003-09-01 Last edit: Last edit:
03-10-13 Graham
Wideman
Go to:
DiagramAntics.com