usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingVisio=Microsoft.Office.Interop.Visio;usingAxVisOcx=AxMicrosoft.Office.Interop.VisOcx;//usingSystem.Web.UI.WebControls;usingCell=Microsoft.Office.Interop.Visio.Cell;
namespacevisiotest1{publicpartialclassForm2:Form{publicForm2(){InitializeComponent();}
privatestaticvoidConnectShapes(Visio.Shapeshape1,Visio.Shapeshape2,Visio.Shapeconnector){//getthecellfromthesourcesideoftheconnector
CellbeginXCell=connector.get_CellsSRC(
(short)Visio.VisSectionIndices.visSectionObject,
(short)Visio.VisRowIndices.visRowXForm1D,
(short)Visio.VisCellIndices.vis1DBeginX);
//gluethesourcesideoftheconnectortothefirstshape
beginXCell.GlueTo(shape1.get_CellsSRC(
(short)Visio.VisRowIndices.visRowXFormOut,
(short)Visio.VisCellIndices.visXFormPinX));
//getthecellfromthedestinationsideoftheconnector
CellendXCell=connector.get_CellsSRC(
(short)Visio.VisCellIndices.vis1DEndX);
//gluethedestinationsideoftheconnectortothesecondshape