Link to home
Start Free TrialLog in
Avatar of guessdip
guessdip

asked on

How to fixed lenth of string in node in treeview in c#?

Hii All Experts,
 
  I am using WSS 3.0. and i made some custom web parts in C#. i made Treeview Web parts.

I display Treenode with big String. i have combine 6 columns in parent node. but it looks bad. i just want to fix lentgh
for every column so i can dispay parent node in table grid format.

Like i need to write code if character above 10 then dispay in new line. So is it possible with string function.
i am attaching image and code also..

Let me know if you dont understand my question.

project.Text = "<b> <Font Color=Orange>" + " Projects List =>" + "</font></b>" + "  <b> <Font Color=Green>" + itemdata1["Title"].ToString() + "</font></b>" + "<font color=Red>" + "--" + "</font>" + Phase + "<font color=Red>" + "--" + "</font>" +  State +  "<font color=Red>" + "--" + "</font>" + finaldispstate + "<font color=Red>" + "--" + "</font>" + DisSD + "<font color=Red>" + "--" + "</font>" + DisED + "<font color=Red>" + "--" + "</font>" + PlaSD + "<font color=Red>" + "--" + "</font>" + PlaED + "<font color=Red>" + "--" + "</font>" + DecomSD + "<font color=Red>" + "--" + "</font>" + DecomED + "<font color=Red>" + "--" + "</font>" + RemSD + "<font color=Red>" + "--" + "</font>" + RemED + "<font color=Red>" + "--" + "</font>" + PostSD + "<font color=Red>" + "--" + "</font>" + PostED + "<font color=Red>" + "--" + "</font>" + itemdata["Track"].ToString() + "<font color=Red>" + "--" + "</font>" + itemdata["SubTrack"].ToString() + "<b> <Font Color=Blue>" + "|" + "</b> </Font>" + "<b> <Font Color=Orange>" + "|" + " Scratch =>" + "</font></b>" + "  <b> <Font Color=Green>" + itemdata1["Title"].ToString() + "</font></b>" + "<font color=Red>" + "--" + "</font>" + itemdata1["Phase"].ToString() + "<font color=Red>" + "--" + "</font>" + itemdata1["State"].ToString() + "<font color=Red>" + "--" + "</font>" + itemdata1["FinalDispState"].ToString() + "<font color=Red>" + "--" + "</font>" + itemdata1["Track"].ToString() + "<font color=Red>" + "--" + "</font>" + itemdata1["SubTrack"].ToString();

Open in new window

Avatar of guessdip
guessdip

ASKER

Hii,
I am attaching image of my tree. I just want to use tree node in table format. i used 15 to 20 columns in parent node.
Tree.bmp
Working with strings will never give you a perfect table view.

itemdata1["Title"].ToString().Remove(15,itemdata1["Title"].ToString().Length-15) + "...";
is a way to cut off the strings.

Hii,
 But i also want to display rest of the string in new line. is it possible???
You can try
itemdata1["Title"].ToString().Remove(15,itemdata1["Title"].ToString().Length-15) +"<br/>" + itemdata1["Title"].ToString().Remove(0,15)

but you should put an "if" in front to make sure the string is that long :)
Hii MsShadow
 Thanks for helping me. i tried this. but i dont want to display whole string in new line. i just wanted to display this column in new line. rest of the string i would like to display in same line. i will tell you what i need.
Before:: Project A -- Start - Need Resource-- Test
              Project Need - Start - Need Resouse - Test
After:    Project A -- Start - Need Resource-- Test
             Project N  -- Start - Need Resource-- Test
             eed

Hope you understand..
Then just put the <br/> where you want the new line to start.
For instance, if you wan the new line to start at State, just use this
"</font><br/>" +  State +  "<font color=Red>"
You just put the <br/> after the </font> tag
Hii MsShadow,
 i did it. but rest of string i got in new line. and i need only some character of project in new line. rest of the string i need in same line. if i use <br. </br> command then it looks like..

Project N
            eed - State-....
But i need Project N  - state -....
                             eed
ASKER CERTIFIED SOLUTION
Avatar of MsShadow
MsShadow
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey MsShadow,
  I got it for first column. Now i will try for same second and third column by this command. Thanks for helping me. i am learning from you. Hopefully it will work for all columns if require.
Thanks Dude..