473,804 Members | 3,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use images in C# solutions

Hi,

Newbie here, please bear with me.

I have a C# project which implements a tree view control. I want to add
some images to this tree view control. The tree view control represents
the tree view found in Microsoft SQL Server Enterprise Manager. So we
have Server Groups and Servers, in the tree view.

I want to create my own similar tree view and have an image representing
a Server Group, and another image representing a Server. I have these
images as bitmaps in my file system. What is the best way of "managing"
these files? When I develop on my desktop, I reference them like this:

ImageList imgTreeNodes = new ImageList();
imgTreeNodes.Tr ansparentColor = Color.White;
System.Drawing. Image imgServer = Image.FromFile( @"C:\Local Files\Visual
Studio Projects\Squeal Find1.3\SquealF ind\Icons\serve r.bmp");
System.Drawing. Image imgServerGroup = Image.FromFile( @"C:\Local
Files\Visual Studio
Projects\Squeal Find1.3\SquealF ind\Icons\serve rgroup.bmp");
imgTreeNodes.Im ages.Add(imgSer verGroup);
imgTreeNodes.Im ages.Add(imgSer ver);
tvwServers.Imag eList = imgTreeNodes;

However, when I copy my solution to the laptop, the directory structure
is different.

What's the best way of including the images in my solution, but
abstracting it from the file system?

--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk

Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html
Nov 16 '05 #1
4 12238
Two comments here. First of all, when you use the Visual Studio .NET visual
editor to assign images to an Image List, the images are serialized with
your project and compiled as embedded resources, so you don't need to reload
them as external icons.

Second, if you need the images to load from the hard disk, make the images
relative to the executable, then extend
System.Windows. Forms.Applicati on.ExecutablePa th with the relative path to
the images. For example, if the EXE is in c:\myApp\ and the images are
stored in c:\myApp\images \ then use:

string imageLocation = Application.Exe cutablePath + \\images\\myima ge.jpg;

HTH,
Jon
"Mark Allison" <ma***@no.tinne d.meat.mvps.org > wrote in message
news:eD******** *****@TK2MSFTNG P10.phx.gbl...
Hi,

Newbie here, please bear with me.

I have a C# project which implements a tree view control. I want to add
some images to this tree view control. The tree view control represents
the tree view found in Microsoft SQL Server Enterprise Manager. So we
have Server Groups and Servers, in the tree view.

I want to create my own similar tree view and have an image representing
a Server Group, and another image representing a Server. I have these
images as bitmaps in my file system. What is the best way of "managing"
these files? When I develop on my desktop, I reference them like this:

ImageList imgTreeNodes = new ImageList();
imgTreeNodes.Tr ansparentColor = Color.White;
System.Drawing. Image imgServer = Image.FromFile( @"C:\Local Files\Visual
Studio Projects\Squeal Find1.3\SquealF ind\Icons\serve r.bmp");
System.Drawing. Image imgServerGroup = Image.FromFile( @"C:\Local
Files\Visual Studio
Projects\Squeal Find1.3\SquealF ind\Icons\serve rgroup.bmp");
imgTreeNodes.Im ages.Add(imgSer verGroup);
imgTreeNodes.Im ages.Add(imgSer ver);
tvwServers.Imag eList = imgTreeNodes;

However, when I copy my solution to the laptop, the directory structure
is different.

What's the best way of including the images in my solution, but
abstracting it from the file system?

--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk

Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html

Nov 16 '05 #2
> string imageLocation = Application.Exe cutablePath + \\images\\myima ge.jpg;

FYI Outlook Express took out the "'s. One should prefix the first "\\" and
one should come after "jpg".

Jon

"Jon Davis" <jo*@REMOVE.ME. jondavis.net> wrote in message
news:Ot******** *****@TK2MSFTNG P11.phx.gbl...
Two comments here. First of all, when you use the Visual Studio .NET visual editor to assign images to an Image List, the images are serialized with
your project and compiled as embedded resources, so you don't need to reload them as external icons.

Second, if you need the images to load from the hard disk, make the images
relative to the executable, then extend
System.Windows. Forms.Applicati on.ExecutablePa th with the relative path to
the images. For example, if the EXE is in c:\myApp\ and the images are
stored in c:\myApp\images \ then use:

string imageLocation = Application.Exe cutablePath + \\images\\myima ge.jpg;

HTH,
Jon
"Mark Allison" <ma***@no.tinne d.meat.mvps.org > wrote in message
news:eD******** *****@TK2MSFTNG P10.phx.gbl...
Hi,

Newbie here, please bear with me.

I have a C# project which implements a tree view control. I want to add
some images to this tree view control. The tree view control represents
the tree view found in Microsoft SQL Server Enterprise Manager. So we
have Server Groups and Servers, in the tree view.

I want to create my own similar tree view and have an image representing
a Server Group, and another image representing a Server. I have these
images as bitmaps in my file system. What is the best way of "managing"
these files? When I develop on my desktop, I reference them like this:

ImageList imgTreeNodes = new ImageList();
imgTreeNodes.Tr ansparentColor = Color.White;
System.Drawing. Image imgServer = Image.FromFile( @"C:\Local Files\Visual
Studio Projects\Squeal Find1.3\SquealF ind\Icons\serve r.bmp");
System.Drawing. Image imgServerGroup = Image.FromFile( @"C:\Local
Files\Visual Studio
Projects\Squeal Find1.3\SquealF ind\Icons\serve rgroup.bmp");
imgTreeNodes.Im ages.Add(imgSer verGroup);
imgTreeNodes.Im ages.Add(imgSer ver);
tvwServers.Imag eList = imgTreeNodes;

However, when I copy my solution to the laptop, the directory structure
is different.

What's the best way of including the images in my solution, but
abstracting it from the file system?

--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk

Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html




Nov 16 '05 #3
Jon Davis wrote:
string imageLocation = Application.Exe cutablePath + \\images\\myima ge.jpg;

FYI Outlook Express took out the "'s. One should prefix the first "\\" and
one should come after "jpg".


Use Firefox instead! :) Doesn't take anything off :)

Jon

"Jon Davis" <jo*@REMOVE.ME. jondavis.net> wrote in message
news:Ot******** *****@TK2MSFTNG P11.phx.gbl...
Two comments here. First of all, when you use the Visual Studio .NET


visual
editor to assign images to an Image List, the images are serialized with
your project and compiled as embedded resources, so you don't need to


reload
them as external icons.

Second, if you need the images to load from the hard disk, make the images
relative to the executable, then extend
System.Window s.Forms.Applica tion.Executable Path with the relative path to
the images. For example, if the EXE is in c:\myApp\ and the images are
stored in c:\myApp\images \ then use:

string imageLocation = Application.Exe cutablePath + \\images\\myima ge.jpg;

HTH,
Jon
"Mark Allison" <ma***@no.tinne d.meat.mvps.org > wrote in message
news:eD****** *******@TK2MSFT NGP10.phx.gbl.. .
Hi,

Newbie here, please bear with me.

I have a C# project which implements a tree view control. I want to add
some images to this tree view control. The tree view control represents
the tree view found in Microsoft SQL Server Enterprise Manager. So we
have Server Groups and Servers, in the tree view.

I want to create my own similar tree view and have an image representing
a Server Group, and another image representing a Server. I have these
images as bitmaps in my file system. What is the best way of "managing"
these files? When I develop on my desktop, I reference them like this:

ImageList imgTreeNodes = new ImageList();
imgTreeNodes .TransparentCol or = Color.White;
System.Drawi ng.Image imgServer = Image.FromFile( @"C:\Local Files\Visual
Studio Projects\Squeal Find1.3\SquealF ind\Icons\serve r.bmp");
System.Drawi ng.Image imgServerGroup = Image.FromFile( @"C:\Local
Files\Visu al Studio
Projects\Squ ealFind1.3\Sque alFind\Icons\se rvergroup.bmp") ;
imgTreeNodes .Images.Add(img ServerGroup);
imgTreeNodes .Images.Add(img Server);
tvwServers.I mageList = imgTreeNodes;

However, when I copy my solution to the laptop, the directory structure
is different.

What's the best way of including the images in my solution, but
abstractin g it from the file system?

--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk

Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html



Nov 16 '05 #4
You mean Thunderbird? Firefox doesn't do NNTP posting.

Jon

"Andrey" <le*******@yaho o.com> wrote in message
news:dy46d.3592 7$He1.16271@att bi_s01...
Jon Davis wrote:
string imageLocation = Application.Exe cutablePath + \\images\\myima ge.jpg;


FYI Outlook Express took out the "'s. One should prefix the first "\\" and one should come after "jpg".


Use Firefox instead! :) Doesn't take anything off :)

Jon

"Jon Davis" <jo*@REMOVE.ME. jondavis.net> wrote in message
news:Ot******** *****@TK2MSFTNG P11.phx.gbl...
Two comments here. First of all, when you use the Visual Studio .NET


visual
editor to assign images to an Image List, the images are serialized with
your project and compiled as embedded resources, so you don't need to


reload
them as external icons.

Second, if you need the images to load from the hard disk, make the

imagesrelative to the executable, then extend
System.Window s.Forms.Applica tion.Executable Path with the relative path tothe images. For example, if the EXE is in c:\myApp\ and the images are
stored in c:\myApp\images \ then use:

string imageLocation = Application.Exe cutablePath + \\images\\myima ge.jpg;
HTH,
Jon
"Mark Allison" <ma***@no.tinne d.meat.mvps.org > wrote in message
news:eD****** *******@TK2MSFT NGP10.phx.gbl.. .

Hi,

Newbie here, please bear with me.

I have a C# project which implements a tree view control. I want to add
some images to this tree view control. The tree view control represents
the tree view found in Microsoft SQL Server Enterprise Manager. So we
have Server Groups and Servers, in the tree view.

I want to create my own similar tree view and have an image representinga Server Group, and another image representing a Server. I have these
images as bitmaps in my file system. What is the best way of "managing"
these files? When I develop on my desktop, I reference them like this:

ImageList imgTreeNodes = new ImageList();
imgTreeNodes .TransparentCol or = Color.White;
System.Drawi ng.Image imgServer = Image.FromFile( @"C:\Local Files\VisualStudio Projects\Squeal Find1.3\SquealF ind\Icons\serve r.bmp");
System.Drawi ng.Image imgServerGroup = Image.FromFile( @"C:\Local
Files\Visu al Studio
Projects\Squ ealFind1.3\Sque alFind\Icons\se rvergroup.bmp") ;
imgTreeNodes .Images.Add(img ServerGroup);
imgTreeNodes .Images.Add(img Server);
tvwServers.I mageList = imgTreeNodes;

However, when I copy my solution to the laptop, the directory structure
is different.

What's the best way of including the images in my solution, but
abstractin g it from the file system?

--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk

Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html


Nov 16 '05 #5

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

Similar topics

11
8908
by: LarryM | last post by:
Hi, NB, not to stop capturing the single displayed Image, but to stop downloading the entire image directory. (In my Website you will do a search, and get some thumbnails, and these can be enlarged one by one). This topic seems to be frequent. Some says that you under no circumstances can protect your images, others seem to have preventing solutions.
3
18848
by: MediaDesign | last post by:
so there's the problem: my text links have background images and when I put links around images on my page, they too get the background image treatment which I do not...I have tried several possible solutions and nothing has worked: my html code: <div class="borderCCC"> <div class="clients"><a href="../index.html"><img
4
3440
by: Dom Hicklin | last post by:
I have created a form onto which images can be dropped and thus added to the OLE field of a Table (Access 2000 linked to SQL 2000 server). I use the Stephen Lebans ExportOLE function to do this and it creates images on my shared drive beautifully! Being new at this I wondered if there is an easy way of taking the image whatever it's size when pasted and always exporting it as 66*75?
3
5646
by: marwa mohamed | last post by:
salamo alikom hi all when i run report that includes image control linked to a field in the table that contains the image path(on the server)and the record source of the report contains over 30 records a messege shows saying: "Microsoft Access doesn't support the format of the file'file path\filename.jpg' or file is too large.Try converting the file to BMP or GIF format". I want to know which one is the problem (the size) or (the format...
16
1778
by: Fred | last post by:
hi, is there some way to prevent(at least for not so advanced users) image saving on local disk; currently i use javascript which handles the right mouse button click, but all it takes is to disable js in the browser ? TIA
61
4760
by: phil-news-nospam | last post by:
Why does SVG need a different tag than other images? IMHO, SVG should be implemented as an image type just like any other image type, allowing it to work with <img> tags, and ... here is the important part ... also work with backgrounds in other tags. I fail to see any wisdom in making SVG different than say PNG (of course the implementation of the rendering code would obvious be different). --
2
3581
by: OBAFGKM_RNS | last post by:
Let's say I have a Javascript function that loops over and over. In that function i have it alternating images on a button this way: if(var==0){ var myHTML = "<input type='button' style='background-image: url(grnbutt.jpg);etc. etc.'>"; var outq = document.getElementById("qbutt"); outq.innerHTML = myHTML; } else{
1
1574
by: Maxus | last post by:
Hi Everyone, Just wondering if anyone knew of a way to compare images and getting a nearest matching image out of a collection of images of diffrent sizes, colors, etc. Ideally want to compare the general shape of the main features in the image, would be nice if it also compared the average color value. I've done a bit of hunting on google and only really come up with solutions that match pictures based on their file hash value or...
17
2098
by: liketofindoutwhy | last post by:
to simply add two quote images around some text. seems quite simple at first but turns out all the obvious solutions are not as desirable as a perfect solution: please see http://www.0011.com/css/quote.html basically, Style 1 is just inlining the image, text, and image. Style 2 is using a table.
0
9707
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10586
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
10338
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...
0
9161
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
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
5525
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
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
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
3
2997
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.