473,698 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(C ontrolStyles.Us erPaint, true);

this.SetStyle(C ontrolStyles.Al lPaintingInWmPa int, true);
this.SetStyle(C ontrolStyles.Do ubleBuffer, true);
this.SetStyle(C ontrolStyles.Re sizeRedraw, true);
this.SetStyle(C ontrolStyles.Su pportsTranspare ntBackColor,
false);
}

protected override void OnPaintBackgrou nd(PaintEventAr gs pevent)
{
base.OnPaintBac kground(pevent) ;

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

}

}

Aug 15 '08 #1
2 7362

"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(C ontrolStyles.Us erPaint, true);

this.SetStyle(C ontrolStyles.Al lPaintingInWmPa int, true);
this.SetStyle(C ontrolStyles.Do ubleBuffer, true);
this.SetStyle(C ontrolStyles.Re sizeRedraw, true);
this.SetStyle(C ontrolStyles.Su pportsTranspare ntBackColor,
false);
}

protected override void OnPaintBackgrou nd(PaintEventAr gs pevent)
{
base.OnPaintBac kground(pevent) ;

pevent.Graphics .DrawEllipse(pe n, 0, 0, this.Width - 1, this.Height - 1);
}
}
}
When you use ControlStyles.U serPaint 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.comwro te in message
news:4F******** *************** ***********@mic rosoft.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(C ontrolStyles.Us erPaint, true);

this.SetStyle(C ontrolStyles.Al lPaintingInWmPa int, true);
this.SetStyle(C ontrolStyles.Do ubleBuffer, true);
this.SetStyle(C ontrolStyles.Re sizeRedraw, true);
this.SetStyle(C ontrolStyles.Su pportsTranspare ntBackColor,
false);
}

protected override void OnPaintBackgrou nd(PaintEventAr gs pevent)
{
base.OnPaintBac kground(pevent) ;

pevent.Graphic s.DrawEllipse(p en, 0, 0, this.Width - 1, this.Height - 1);
}
}
}

When you use ControlStyles.U serPaint 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
4344
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 problem is that after I multi-select the treenodes, and I try to change the background color of the treeview, those treenodes that have been multi-selected before still
0
1866
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
1882
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! Rogers.
0
1117
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 of using the htc. Any ideas how this can be done for all requests? I have noticed that the Treeview control inherits from the BaseRichControl which has a CheckBrowserLevel method I figure if I can make the web page believe that the browser...
0
1398
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. I coded a test project with a form with a TreeView and an ImageList control. /// Me.TreeView = Me.ImageList
3
3792
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 target node in the treeview and auto expand it if applicable... but after a fair bit of head scratching I can't find any easy way to accomplish this. I think what i really need is the equivalent of the HitTest method from the COM version of the...
18
15369
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 click to make multiple selections. Then when I simply click one item, all previous selections are gone. Thanks in advance.
2
5241
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 node itself, it expands to show its children. It works fine but it is very slow as compared to clicking on + sign to load children. No other event or process runs in the background when i click on the node or the + sign of the folder image. In my...
4
584
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 BackgroundImage property, but this does not seem to work. I'm using C# Express 2008. Does anybody here have any solutions?
0
8600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9156
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4361
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2323
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.