473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 6945
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.GlobalItems.GlobalImages;
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.net> wrote in message
news:6h********************************@4ax.com...
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.net> wrote in message
news:qg********************************@4ax.com...
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
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...
2
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...
7
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...
4
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...
4
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:...
5
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...
6
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....
1
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...
2
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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,...
0
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...
0
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.