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);
}
}
} 2 7346
"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]
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]
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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
|
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!
...
|
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...
|
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.
...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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: 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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |