473,387 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to show Multiline text on TreeView using C# 2005

Hello,

This is my first post, Hello to all. This also a test post to make sure that I am doing the right thing and following rules etc.

I have been searching for a way to make the treeview display multiple lines of text on each treeview node (treenode).

After searching for answers and not finding any, I stumbled on the solution in the msdn help files (search for TreeView.DrawNode Event). It has source code that shows how to display multiple lines of text for a single node.

You need to setup the treeview by changing the drawmode so that the text is draw by the _DrawNode event.

Expand|Select|Wrap|Line Numbers
  1. treeViewForTasks.DrawMode = TreeViewDrawMode.OwnerDrawText;
I assign the node text, putting newlines in where I want. This text will be draw explicitly in the _DrawNode event handler.

Expand|Select|Wrap|Line Numbers
  1. childNode.Text = tr.Name + Environment.NewLine + tr.Description + Environment.NewLine + Environment.NewLine + "Incomplete";
  2.  
In the _DrawNode event handler, draw the node text, using the following code as an example. This code comes directly from the help documentation.

Expand|Select|Wrap|Line Numbers
  1. // Draw the node text.
  2. e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, Rectangle.Inflate(e.Bounds, 2, 0));
This is the result of my efforts so far. It still needs fine tuning, but it works, and thats all I care about at the moment.

Nov 17 '06 #1
1 21571
Here is a small demo of how to make a multiline treeview node



Here is some source code sample App
Feb 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: raj | last post by:
I have multiline-text box in my C# application. User enter text into the multiline-text box, and without completing the whole line, user press Enter Key and go to the next line, by leaving the...
0
by: raj | last post by:
I have multiline-text box in my C# application. User enter text into the multiline-text box, and without completing the whole line, user press Enter Key and go to the next line, by leaving the...
6
by: Iver Erling Årva | last post by:
I am looking for a way to let the users copy e.g. a multi-line address from a textfile and paste it into a webpage where there is one input field for each address line in such a way that not only...
2
by: Chris | last post by:
Hi We are using style sheets to set the font of our labels and text boxes. This has been working great until we required a text box with a textmode of Multiline. The control picks up the...
2
by: amruta | last post by:
How can I write a multiline text in a message box.show how can i use the line feed or carriage return in this situaion. Thank you
2
by: Lakesider | last post by:
Hi NG, I want to use a List Control, that is able to display the following szenario: Customer A New York Revenue: 1200,- € Customer B
6
by: dawnerd | last post by:
Hello everyone. I have a question, or problem if you will, that I'm sure someone knows the answer to. I have a database that stores information on a given user. The information is stored in a...
2
by: myquestion | last post by:
how to hide/show a text box using drop downlist in php
2
by: King | last post by:
Is there any other way to define multiline text in a XML file: <Help><!]> </Help>
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.