472,992 Members | 3,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

TreeView background Image

slg
iam looking for code snippet or a sample of drawing background image for a
c# treeview control.

I tried following but i could not see the tree nodes only the ellipse shows
up.
TIA

public class xtree : System.Windows.Forms.TreeView
{
public xtree()

{

this.SetStyle(ControlStyles.UserPaint, true);

this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.SupportsTransparentBac kColor,
false);
}

protected override void OnPaintBackground(PaintEventArgs pevent)
{
base.OnPaintBackground(pevent);

pevent.Graphics.DrawEllipse(pen, 0, 0, this.Width - 1, this.Height - 1);
}

}

}

Aug 15 '08 #1
2 7320

"slg" wrote:
iam looking for code snippet or a sample of drawing background image for a
c# treeview control.

I tried following but i could not see the tree nodes only the ellipse shows
up.
TIA

public class xtree : System.Windows.Forms.TreeView
{
public xtree()

{

this.SetStyle(ControlStyles.UserPaint, true);

this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.SupportsTransparentBac kColor,
false);
}

protected override void OnPaintBackground(PaintEventArgs pevent)
{
base.OnPaintBackground(pevent);

pevent.Graphics.DrawEllipse(pen, 0, 0, this.Width - 1, this.Height - 1);
}
}
}
When you use ControlStyles.UserPaint you are telling the system that it
should stop drawing the TreeView since you are going to do it. Since you
only draw the background you won't see any nodes in the tree.

I'm afraid that if you want a custom background you will also have to draw
the foreground.

--
Happy Coding!
Morten Wennevik [C# MVP]
Aug 15 '08 #2
slg
Thx!

"Morten Wennevik [C# MVP]" <Mo************@hotmail.comwrote in message
news:4F**********************************@microsof t.com...
>
"slg" wrote:
> iam looking for code snippet or a sample of drawing background image for
a
c# treeview control.

I tried following but i could not see the tree nodes only the ellipse
shows
up.
TIA

public class xtree : System.Windows.Forms.TreeView
{
public xtree()

{

this.SetStyle(ControlStyles.UserPaint, true);

this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.SupportsTransparentBac kColor,
false);
}

protected override void OnPaintBackground(PaintEventArgs pevent)
{
base.OnPaintBackground(pevent);

pevent.Graphics.DrawEllipse(pen, 0, 0, this.Width - 1, this.Height - 1);
}
}
}

When you use ControlStyles.UserPaint you are telling the system that it
should stop drawing the TreeView since you are going to do it. Since you
only draw the background you won't see any nodes in the tree.

I'm afraid that if you want a custom background you will also have to draw
the foreground.

--
Happy Coding!
Morten Wennevik [C# MVP]

Aug 15 '08 #3

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

Similar topics

2
by: Sean | last post by:
Hi all, I have a treeview and because I subclass the treeview and allow multiple selection to be done on the treeview, I have a problem changing the background color of the treeview. The...
0
by: kiran | last post by:
How to set background image for treeview control or transparent color as a background for treeview control in Windows forms..? Regards kiran
2
by: Rogers | last post by:
Hi,everyone: I want to add a background image to treeview control on my asp.net page,or if I can make it to be transparent,that would be okay to.if there and way to implement it? Thank you! ...
0
by: richie_hackett | last post by:
OK I have been tearing my hair out trying to get the Treeview webcontrol to display a background image. My current thinking is that mozilla allows you to render the treeview as a table instead...
0
by: Sarika | last post by:
Hi, I am a little confused about associating an image w/ the VB.NET TreeView Control. My specific requirement is that I want to associate an image w/ some specific nodes in the TreeView only. ...
3
by: Gary Dunne | last post by:
I'm writing an app that requires drag and drop operation between a ListView and a TreeView control. (The source is the ListView). During the drag drop operation I want to be able to detect the...
18
by: =?Utf-8?B?TGkgV2VuZw==?= | last post by:
Hi, Is there a way for TreeView to have multiple selections? But I am not talking about its checked boxes. I want a way similar to ListView with MultiSelect = True. So I can use or key and...
2
by: =?Utf-8?B?QU5V?= | last post by:
I have a tree view which i load completely at the time of my webpage load. When i click on the + signs of the parent nodes, it expands to show all of its children. Similarly, when i click on the...
4
by: =?Utf-8?B?UGF0cmlja1M=?= | last post by:
I'd like to be able to give a treeview in my application a nice smooth gradient as a background image, but I'm having trouble doing this. Webpages that I've seen so far seem to suggest using the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.