how to start a new text line inside the visio shape paragraph

M

Memo

Dear all

is there any one know how to start a new text line inside the visio shape
paragraph by using .net, what i'm trying to do is inserting some text into
the visio shape and this start a new line to insert another text. i have been
tried to use the "\n" or "\n\r" or (char)13 to start the new line but it
didnt work, and it look like this

SHAPE.Text = "first line"

SHAPE.Begin = SHAPE.End

SHAPE.Text = (the new line char)

SHAPE.Begin = SHAPE.End

SHAPE.Text = "Next line"

thanks you very much
 
C

Chris Roth [MVP]

Hi Memo,

It worked for me to build the string with \n. What I did was build one
string with all the lines of text, then set the shape text with one line of
code.

Have a look at this sample:

using Vis = Microsoft.Office.Interop.Visio;

private void button1_Click(object sender, EventArgs e)
{
// Get the Visio application object:
Vis.Application visApp = (Vis.Application)
System.Runtime.InteropServices.Marshal.GetActiveObject("visio.application");

// Get the selected shape:
Vis.Shape visShp = visApp.ActiveWindow.Selection[1];

// Build a string
String s = "Line one\nLine two\nLine three";

// Set the text
visShp.Text = s;
}




--
Hope this helps,

Chris Roth
Visio MVP

Free Visio shapes:
http://www.visguy.com/category/shapes
Visio programming info:
http://www.visguy.com/category/programming/
Other Visio resources:
http://www.visguy.com/visio-links/
 
M

Memo

Thanks chris.
But it didn’t solve the problem, I have been retry to do it as you advised
me and it didn’t work, what have I done is look like the following
Shape.Text = “First line\n2nd line†+ Convert.ToString(Convert.ToChar(13)) +
“3rd lineâ€
But both of them didn’t solve the problem , and if it can help I’m using
organization chart shapes
 
M

Memo

thanks Chris
i was wrong your solution is work very well but my problem was that my code
was on VB and i used to be a c# developer for that i have been forget to add
a new line in VB i have to use vbLF in to the text

thanks you very much
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top