473,503 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

treeview

hi i have a set of bitmaps in an array.
and i want to add it to a imagelist so that i can show those images in my
treeview.
imageList2.Images.Add (Image.FromHbitmap (picture.Bitmap)); //cant use this
gives me an error

do i need to convert from bitmap to a memory stream?

thanx
Nov 16 '05 #1
3 4769
The following is an exact example which works:

Image i = (Image)Bitmap.FromFile(@"C:\WINDOWS\blue lace 16.bmp");
ImageList il = new ImageList();

il.Images.Add(i);

TreeView tv = new TreeView();

tv.ImageList = il;
tv.Nodes.Add("root");
tv.Nodes[0].ImageIndex = 0; //set the image to the first item

this.Controls.Add(tv);

Cheers,
Branimir
--
Branimir Giurov
MCSD.NET, MCDBA
eAgility LLC
"frazer" <ic***@hotmail.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
hi i have a set of bitmaps in an array.
and i want to add it to a imagelist so that i can show those images in my
treeview.
imageList2.Images.Add (Image.FromHbitmap (picture.Bitmap)); //cant use this gives me an error

do i need to convert from bitmap to a memory stream?

thanx

Nov 16 '05 #2
frazer wrote:
hi i have a set of bitmaps in an array.
and i want to add it to a imagelist so that i can show those images in my
treeview.
There is ImageList.ImageSize property that should correspond with
size of images. If it isn't then images will be resized (with
possible loss of quality).
imageList2.Images.Add (Image.FromHbitmap (picture.Bitmap)); //cant use this
gives me an error
I believe that your picture.Bitmap does not returns IntPtr.
ImageList.ImageCollection.Add method takes "Image" or "Icon" parameter.
do i need to convert from bitmap to a memory stream?

thanx


try this:

Bitmap[] bmpArray; // your array of bitmaps

// ... bmpArray fill

for(int i=0; i<bmpArray.Length; i++) {
imageList2.Images.Add(bmpArray[i]);
}

If my sample will not do what you want or throws exception
then send feedback with possible StackTrace.

Regards

Marcin
Nov 16 '05 #3
Hi,

I think your approach is a little bit overcomplicated. The Add method
accepts a System.Drawing.Image, and System.Drawing.Bitmap is inherited from
System.Drawing.Image. So it should be sufficient to use the following code
(given the Bitmap property returns an instance of System.Drawing.Bitmap):

imageList2.Images.Add (picture.Bitmap);

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

"frazer" <ic***@hotmail.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
hi i have a set of bitmaps in an array.
and i want to add it to a imagelist so that i can show those images in my
treeview.
imageList2.Images.Add (Image.FromHbitmap (picture.Bitmap)); //cant use this gives me an error

do i need to convert from bitmap to a memory stream?

thanx


Nov 16 '05 #4

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

Similar topics

42
11470
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
5
19867
by: SoKool | last post by:
Can anyone point me to a site where I can get a free treeview control to use in ASP .NET or any tutorial that can help me build my own treeview control. I intend to use a treeview to generate a...
1
6655
by: paradox | last post by:
I want to have a TreeView that shows an image on some items, but not all. Basically, if a certain condition is true, a caution icon is placed next to the treeview item. The problem is that, by...
3
2817
by: Peter | last post by:
Hello, We are inserting a side menu to our application using a class that is writing HTML on all our pages. This is a part of the code as an example: writer.Write(" <table WIDTH=""100%""...
6
4913
by: L.M | last post by:
Hello, I knew how to use the treeview under VB6. After migrating to .NET, well, I'm lost. I try to add a new node, either to the same level or as a child to a selected node in the treeview....
14
15050
by: Mr.D | last post by:
How do I save/load the contents of a Treeview to a file? I have found several good examples written i VB6, but not a single one for VB.NET. Please help. ---- Tim
3
3800
by: christof | last post by:
I've got a really easy problem, please help me: There are two pages in one I'm creating a TreeView like that: TreeView dbTree = new TreeView(); TreeNode dbTreeRoot = new TreeNode("Root");...
2
7479
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView...
1
693
by: kvicky | last post by:
I am trying to load child nodes to a TreeNode in a TreeView in a ASP.net web application. The Treeview with parent nodes are loaded on a Page_load while doing if( ! ISPostback ) and then in the...
8
12727
by: Matt MacDonald | last post by:
Hi All, I have a form that displays hierarchical categories in a treeview. Ok so far so good. What I was to do is have users be able to select a node in the treeview as part of filling out the...
0
7199
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
7074
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
7322
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...
1
6982
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...
0
7451
tracyyun
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...
0
3161
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...
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.