473,326 Members | 2,090 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,326 software developers and data experts.

Treeview Custom Paint


Hi All,

How do I create a custom paint treeview control or an
owner drawn treeview control ?

Any tutorials on this anywhere?

Thanks,
JJBean
Nov 15 '05 #1
8 10727
Hi,

There's an article on VB Accelerator outlining how this is done in VB6:

http://www.vbaccelerator.com/home/VB...ol/article.asp

Since it comes down to plain Win32 API, I think you should be able to
implement the same approach in C#. Pay most of your attention to how the
NM_CUSTOMDRAW notification is handled as this is the most useful part of the
code accompanying the article for you to start from.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"JJBean" <an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...

Hi All,

How do I create a custom paint treeview control or an
owner drawn treeview control ?

Any tutorials on this anywhere?

Thanks,
JJBean


Nov 15 '05 #2
i havent checked out this article yet, but do you know
offhand if it is it possible to draw single nodes for the
TreeView? (for instance to allow mixing of regular and
italic text)

Thanks!

-----Original Message-----
Hi,

There's an article on VB Accelerator outlining how this is done in VB6:
http://www.vbaccelerator.com/home/VB...ontrols/TreeVi ew/TreeView_Control/article.asp
Since it comes down to plain Win32 API, I think you should be able toimplement the same approach in C#. Pay most of your attention to how theNM_CUSTOMDRAW notification is handled as this is the most useful part of thecode accompanying the article for you to start from.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"JJBean" <an*******@discussions.microsoft.com> wrote in messagenews:05****************************@phx.gbl...

Hi All,

How do I create a custom paint treeview control or an
owner drawn treeview control ?

Any tutorials on this anywhere?

Thanks,
JJBean


.

Nov 15 '05 #3
I DO know ohh-hand this is possible. I have even done it myself by drawing a
number of child nodes in parenthes in a different color (much like Outlook
Express does).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"woodBeeProgrammer" <wo***************@spamex.com> wrote in message
news:04****************************@phx.gbl...
i havent checked out this article yet, but do you know
offhand if it is it possible to draw single nodes for the
TreeView? (for instance to allow mixing of regular and
italic text)

Thanks!

-----Original Message-----
Hi,

There's an article on VB Accelerator outlining how this

is done in VB6:

http://www.vbaccelerator.com/home/VB...ontrols/TreeVi

ew/TreeView_Control/article.asp

Since it comes down to plain Win32 API, I think you

should be able to
implement the same approach in C#. Pay most of your

attention to how the
NM_CUSTOMDRAW notification is handled as this is the

most useful part of the
code accompanying the article for you to start from.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"JJBean" <an*******@discussions.microsoft.com> wrote in

message
news:05****************************@phx.gbl...

Hi All,

How do I create a custom paint treeview control or an
owner drawn treeview control ?

Any tutorials on this anywhere?

Thanks,
JJBean


.


Nov 15 '05 #4
Dmitriy, thanks, but how? (there is no
TreeNode.OnPaint :))

-----Original Message-----
I DO know ohh-hand this is possible. I have even done it myself by drawing anumber of child nodes in parenthes in a different color (much like OutlookExpress does).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"woodBeeProgrammer" <wo***************@spamex.com> wrote in messagenews:04****************************@phx.gbl...
i havent checked out this article yet, but do you know
offhand if it is it possible to draw single nodes for the TreeView? (for instance to allow mixing of regular and
italic text)

Thanks!

>-----Original Message-----
>Hi,
>
>There's an article on VB Accelerator outlining how this
is done in VB6:
>

http://www.vbaccelerator.com/home/VB...ontrols/TreeVi
ew/TreeView_Control/article.asp
>
>Since it comes down to plain Win32 API, I think you

should be able to
>implement the same approach in C#. Pay most of your

attention to how the
>NM_CUSTOMDRAW notification is handled as this is the

most useful part of the
>code accompanying the article for you to start from.
>
>--
>Dmitriy Lapshin [C# / .NET MVP]
>X-Unity Test Studio
>http://x-unity.miik.com.ua/teststudio.aspx
>Bring the power of unit testing to VS .NET IDE
>
>"JJBean" <an*******@discussions.microsoft.com> wrote
in message
>news:05****************************@phx.gbl...
>>
>> Hi All,
>>
>> How do I create a custom paint treeview control

or an >> owner drawn treeview control ?
>>
>> Any tutorials on this anywhere?
>>
>> Thanks,
>> JJBean
>
>.
>


.

Nov 15 '05 #5
Right, there's no such thing. You should resort to overriding the tree's
parent control WndProc and handling WM_NOTIFY messages sent by the tree to
its parent. You will be interested in the NM_CUSTOMDRAW notification.

Please refer to Common Controls documentation in the MSDN Library for more
information. As the Framework provides no managed means to facilitate custom
drawing, plain Windows API is your only choice.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"woodBeeProgrammer" <wo***************@spamex.com> wrote in message
news:09****************************@phx.gbl...
Dmitriy, thanks, but how? (there is no
TreeNode.OnPaint :))


Nov 15 '05 #6
thanks for the response, but i'm not clear what you mean or what you did in
your Outlook bar type application.

Does the TreeView draw its window as a whole, or is it done node by node?
Can i write code for just one node, or do i need to manage the whole window?

TIA!
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:eJ**************@tk2msftngp13.phx.gbl...
Right, there's no such thing. You should resort to overriding the tree's
parent control WndProc and handling WM_NOTIFY messages sent by the tree to
its parent. You will be interested in the NM_CUSTOMDRAW notification.

Please refer to Common Controls documentation in the MSDN Library for more
information. As the Framework provides no managed means to facilitate custom drawing, plain Windows API is your only choice.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"woodBeeProgrammer" <wo***************@spamex.com> wrote in message
news:09****************************@phx.gbl...
Dmitriy, thanks, but how? (there is no
TreeNode.OnPaint :))

Nov 15 '05 #7
TreeView allows for both of the approaches. I personally did custom node
drawing, as drawing all these connecting lines and [+] icons myself would be
such a pain! More than that, you can tell the TreeView to paint a node, and
then add something to what was painted by the tree view itself (it's exactly
what I did). If we take Outlook Express an an example, and assume there is
no need to have bold-face nodes, we should let the standard treeview to draw
the node text and the node icon, and then we will draw the number in
parenthes ourselves by using different color.

Please refer to the NM_CUSTOMDRAW notification message documentation - it
explains all custom drawing stages in detail.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"woodBeeProgrammer" <wo***************@spamex.com> wrote in message
news:vu************@corp.supernews.com...
thanks for the response, but i'm not clear what you mean or what you did in your Outlook bar type application.

Does the TreeView draw its window as a whole, or is it done node by node?
Can i write code for just one node, or do i need to manage the whole window?
TIA!


Nov 15 '05 #8
Dmitriy, thanks. If anyone is interested, a sample for NM_CUSTOMDRAW is
CustDTv, currently at
http://support.microsoft.com/default...;EN-US;q248496 (wow, did
people ever program like that? sure looks almost like assembler!!)

Thanks again Dmitriy!
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:u4*************@TK2MSFTNGP11.phx.gbl...
TreeView allows for both of the approaches. I personally did custom node
drawing, as drawing all these connecting lines and [+] icons myself would be such a pain! More than that, you can tell the TreeView to paint a node, and then add something to what was painted by the tree view itself (it's exactly what I did). If we take Outlook Express an an example, and assume there is
no need to have bold-face nodes, we should let the standard treeview to draw the node text and the node icon, and then we will draw the number in
parenthes ourselves by using different color.

Please refer to the NM_CUSTOMDRAW notification message documentation - it
explains all custom drawing stages in detail.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"woodBeeProgrammer" <wo***************@spamex.com> wrote in message
news:vu************@corp.supernews.com...
thanks for the response, but i'm not clear what you mean or what you did

in
your Outlook bar type application.

Does the TreeView draw its window as a whole, or is it done node by node? Can i write code for just one node, or do i need to manage the whole

window?

TIA!

Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Daisy | last post by:
I'm writing a NewsReader (seemed like a decent project to start learning with), and want threading like in OE. I've got a treeview and a listview. On Expand/Contract on the listview, I spin...
1
by: sho_nuff | last post by:
Hello, It appears that i may need to create a custom treeview. I have a set of nodes - sometimes, if a user selects an option , i may want to only display a subset of those nodes... and i...
6
by: Dean L. Howen | last post by:
Hi, I want to add some attributes to TreeNode, so I create a new class MyNode that inheritance from System.Windows.Forms.TreeNode, I want to TreeView use MyNode instead of TreeNode, so I can...
1
by: Benny Raymond | last post by:
I'm trying to adjust the length of the strings being drawn, as well as some effects depending on what item is actually being drawn. I tried doing the following, but the paint event never runs: ...
2
by: Slava ilyin | last post by:
Hi! Does anyone know how to get TreeNode RECT using VB.NET? My code is below seems to be incorrected. What is wrong? (sorry, I'm a novice in .NET) \\\ Private Declare Function SendMessage...
7
by: vsiat | last post by:
I am trying to create a treeview out of a database table with the typical structure ID, NAME, PARENTID, TYPE, EXTRA_INFO, where is linked to the . What I want to achieve is create a tree made...
1
by: nate axtell | last post by:
In VB .Net I made a custom CheckBox column style (for the Datagrid control) that maps to two DataTable columns , one it uses for the Checked status and the other it uses for the Enabled status. I am...
2
by: kevin | last post by:
I would like to remember the state of the nodes after the treeview gets disposed, but not necessarily after the app terminates so I don't need a disk file. I was thinking about using the tag...
8
by: Jon Slaughter | last post by:
I'm trying to override the default paiting of a treeview but I get bad results: My code(well, atleast this is the most simple that reproduces the result) is this private void TVDrawNode(Object...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.