473,626 Members | 3,031 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A global ImageList ?

Hi,

I have an ImageList and I want to use it at design time in several forms,
how can I do it ?

Ok, I can copy the ImageList from one form and paste it on the new form,
but these ImageLists are then duplicate.

Thanks
Dec 21 '05 #1
4 6966
create static class somewhere, maybe Program.cs that loads the image list
into a variable.

public static class GlobalItems
{
private static ImageList _imgList=null;

public static ImageList GlobalImages
{
get
{
if (_imgList == null)
LoadImages();
return _imgList;
}
}

private static void LoadImages()
{
// Put your loading code here
}
}

then where ever you need to use it call

Namespace.Globa lItems.GlobalIm ages;
If you are setting the ImageList at DesignTime, you might need to change the
Form1.Designer. cs file.
Dec 21 '05 #2
Omega,

Is the image list going to be shared at runtime also. I don't think this is
a good OO design. If you need the image list just in design time you can
create and register a service upon loading your designer. Then you can look
for this service and get the image list from there in all your designers.
--

Stoitcho Goutsev (100) [C# MVP]

"Omega" <om*****@gmx.ne t> wrote in message
news:6h******** *************** *********@4ax.c om...
Hi,

I have an ImageList and I want to use it at design time in several forms,
how can I do it ?

Ok, I can copy the ImageList from one form and paste it on the new form,
but these ImageLists are then duplicate.

Thanks

Dec 22 '05 #3
On Thu, 22 Dec 2005 09:38:05 -0500, "Stoitcho Goutsev \(100\) [C# MVP]"
<10*@100.com> wrote:
Omega,

Is the image list going to be shared at runtime also. I don't think this is
a good OO design. If you need the image list just in design time you can
create and register a service upon loading your designer. Then you can look
for this service and get the image list from there in all your designers.


Hi,

Sure, I want these images to be shared at rumtime also.

The problem: I have same buttons like 'Search' / 'Info' on different forms,
the button has an icon on the left, I can choose the icon from the
ImageList which is already resized (16x16). Everything is ok but the
ImageList must be on every form.

I tried to create a resource for the project and add icons to it, it will
be global for all the forms in the project, in button's Image propertys I
then choose the resource icon but it can't be resized, it is always the
first icon in the Ico file (48x48).

Create and register a service ? I don't know how to do it ...

Omega

Dec 23 '05 #4
Omega,

I don't think is a necessary a bad idea to have image list on each form.
Anyways, look at Icon class constructors, there are overloads that accept
size. Besically you load an icon form the resource and then create a new
Icon instance out of the loaded one specifying the size. This will extract
the icon with sepcified size.

Icon icon = new Icon(typeof(... ), "MyIcon.ico ");
Icon icon16 = new Icon(icon, 16,16);
There is also overlaod that accept stream and size. I think it works on the
same way, but never tried it.

As you can pick different image sizes there is no solution for getting same
size, but different color depth For example if you have and icon file with
images 16x16x16 and 16x16x256 you cannnot cotrol which one the Icon
constructor will pick. My test shows it picks 256-color one.
--
HTH
Stoitcho Goutsev (100) [C# MVP]

"Omega" <om*****@gmx.ne t> wrote in message
news:qg******** *************** *********@4ax.c om...
On Thu, 22 Dec 2005 09:38:05 -0500, "Stoitcho Goutsev \(100\) [C# MVP]"
<10*@100.com> wrote:
Omega,

Is the image list going to be shared at runtime also. I don't think this
is
a good OO design. If you need the image list just in design time you can
create and register a service upon loading your designer. Then you can
look
for this service and get the image list from there in all your designers.


Hi,

Sure, I want these images to be shared at rumtime also.

The problem: I have same buttons like 'Search' / 'Info' on different
forms,
the button has an icon on the left, I can choose the icon from the
ImageList which is already resized (16x16). Everything is ok but the
ImageList must be on every form.

I tried to create a resource for the project and add icons to it, it will
be global for all the forms in the project, in button's Image propertys I
then choose the resource icon but it can't be resized, it is always the
first icon in the Ico file (48x48).

Create and register a service ? I don't know how to do it ...

Omega

Dec 23 '05 #5

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

Similar topics

2
2302
by: Bob C. | last post by:
Hi All, I am using the ImageList/ListView Components to display around 100 images in C#.NET. The issue i have is, some times i may need to display the thumbnail of size more then 256x256 in ImageList. But the ImageList Component supports only size upto 256x256. What is the best way to handle this?
2
8524
by: Sanjeeva Reddy | last post by:
hai Anti Keskinen, i have used the following code MyListView->LargeImageList->ImageSize = gcnew System::Drawing::Size(100, 100); // Sets large image size to 100, 100 here i am getting error like "gcnew is undeclared error",how to deeclare 'gcnew" and when i am using in runtime to change the size of images in imagelist in listview control in .net(forms application) by chnging one trckbar(like tb1->Value),
7
2094
by: Andrew Christiansen | last post by:
Hey everyone. I have Visual Basic .NET 2003 and am trying to show images on a treeview control. I have the imagelist on the form filled with images, and have the ImageList property of the treeview control set to the imagelist containing the images I want to be displayed next to each node. It seems that no matter what I do there will be no images displayed next to the nodes during runtime. I tried creating nodes during designtime using...
4
4325
by: David | last post by:
I have a problem that just cropped up with using an ImageList in my project I am using VB .NET 200 Problem: I have existing Form with 2 Image List controls. ImageList16 (for 16x16 Images) and ImageList24 (for 24x24). I have inserted images in each and it has worked fine for months... The System.Drawing.Bitmap properties for these images are PixelFormat=32bppArgb and RawFormat=MemoryBmp with the Horiz and VerticalResolution = 96 I...
4
2192
by: Just Me | last post by:
If I add an image to an imagelist using imageList.Images.Add... And use it with a tree node tn.ImageIndex = imageList.Images.Count-1 This is the actual code: Win32.Shell.SHGetFileInfo(NodePath, 256, fileinfo, cbFileInfo, flags) tvFolders.ImageList.Images.Add(Icon.FromHandle(fileinfo.hIcon)) tn.ImageIndex = tvFolders.ImageList.Images.Count - 1
5
3538
by: | last post by:
I do not want to setup and create my ImageList over and over again on different forms in my project. Is there any ways to achieve it? so that I will be more easy to manage my ImageList as well as minimize the performance overhead. Thanks~
6
3024
by: henrycortezwu | last post by:
Hi, I have a WinXPSP2, P4 3.2GHZ, 1GIG RAM on my dev machine using VS2005 VB.NET. I did the following procedure: 1. Added 82 icons (128x128 in size & 32bit Depth) in an imagelist control 2. Save the project 3. Complied the project (successful) 4. Closed the project 5. Opened the project
1
1784
by: Sagaert Johan | last post by:
Hi In my topform i have an imagelist with icons used through the whole application.(main project + control libs) Can i make this imagelist global so i do not have to pass the imagelist object through all class layers used in my app? Johan
2
3555
by: =?Utf-8?B?S2VuTg==?= | last post by:
We're using a System.Windows.Forms.ImageList to store a bunch of Images that I've loaded, and rendering each image in the ImageList during a draw loop. The process was running unusually slow and was causing memory spikes. After several hours we discovered that the ImageList.Images indexer is actually returning a copy of the added Images instead of simply returning a reference. Needless to say, we were a bit surprised and disturbed to...
0
8196
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
8701
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
8637
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
8364
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
6122
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
4090
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
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2623
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 we have to send another system
1
1807
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.