473,394 Members | 1,773 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,394 software developers and data experts.

Listing Images in a List Box

Hello,

I would like to know if anyone as found a way to
list a image next to a list box to indicate what type of
drive (local or network) and a folder

I would like to present in a user interface like the OpenFileDialog
that has a pulldown(at the top of the dialog) to allow a user
to navigate a directory/folder selection.

I am just looking to extracted the Drive and folder only.
This code fragment will list drive letters and folders.

Dim dirInfo as Directory
Dim drive,dirpath as string

Me.ComboBox1.Items.Clear()

dim drives() as string = dirInfo.GetLogicalDrives()
For Each drive in drives
Try
Dim paths() as string = Director.GetDriectories(drive) 'Only grab
drives that are available
For Each dirpath in paths
Me.ComboBox1.Items.Add(dirpath)
Next
Catch ' ignore errors/drives that are not ready ie A:\ or a CD or
DVD drive...

End Try

Me.ComboBox1.SelectedIndex = 1 ' Now select the first Item found

I would like to list the images just like the OpenFileDialog to give the
user a graphical representation
of the directories and paths found.

Thank you


Nov 20 '05 #1
4 1977
Cor
Hi James,

You ask a listbox, the answer on that is easy use a listview, but then I saw
your code is about a combobox.

And if it is a combobox, then did you see it before somewhere, when not, you
mostly have to draw it yourself.

Cor
Nov 20 '05 #2
>I would like to know if anyone as found a way to
list a image next to a list box to indicate what type of
drive (local or network) and a folder


If you are using a combobox then set the draw property to
OwnerDrawVariable and then implement the ItemDraw event of the control
(you'll need an image list with the images you want to use):

<code>
Private Sub MyCombo_DrawItem(ByVal sender As Object, ByVal e As
System.Windows.Forms.DrawItemEventArgs) Handles MyCombo.DrawItem
'Places icon for the tag next to the tag text

Dim MyText as String = "My Item Text"

e.DrawBackground()
MyImages.Draw(e.Graphics, e.Bounds.Location,
SelectedTag.ImageIndex)
e.Graphics.DrawString(MyText, Font, New
SolidBrush(e.ForeColor), e.Bounds.X + MyImages.ImageSize.Width,
e.Bounds.Y)
e.DrawFocusRectangle()

End Sub
</code>

Hope this helps.

Tom
Nov 20 '05 #3
* "James Kunicki" <ji***@snet.net> scripsit:
I would like to know if anyone as found a way to
list a image next to a list box to indicate what type of
drive (local or network) and a folder


Why not use a ListView control instead?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
It sounds like you just want the user to be able to select a folder. Why
don't you use the Folder Browser Dialog Control. I believe it was made
available with Visual Studio 2003.

"James Kunicki" <ji***@snet.net> wrote in message
news:ep**************@TK2MSFTNGP10.phx.gbl...
Hello,

I would like to know if anyone as found a way to
list a image next to a list box to indicate what type of
drive (local or network) and a folder

I would like to present in a user interface like the OpenFileDialog
that has a pulldown(at the top of the dialog) to allow a user
to navigate a directory/folder selection.

I am just looking to extracted the Drive and folder only.
This code fragment will list drive letters and folders.

Dim dirInfo as Directory
Dim drive,dirpath as string

Me.ComboBox1.Items.Clear()

dim drives() as string = dirInfo.GetLogicalDrives()
For Each drive in drives
Try
Dim paths() as string = Director.GetDriectories(drive) 'Only grab
drives that are available
For Each dirpath in paths
Me.ComboBox1.Items.Add(dirpath)
Next
Catch ' ignore errors/drives that are not ready ie A:\ or a CD or
DVD drive...

End Try

Me.ComboBox1.SelectedIndex = 1 ' Now select the first Item found

I would like to list the images just like the OpenFileDialog to give the
user a graphical representation
of the directories and paths found.

Thank you

Nov 20 '05 #5

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

Similar topics

15
by: Kim Jensen | last post by:
I'd like to make a directory listing where instead of the entire filename I need it to show the filename minus the extention and get the value of charname= in the file itself. I've been told...
1
by: Gema Gema | last post by:
I have a large collection of directories full of various files and am looking to create custom text files for the contents of each directory. Here is the situation: The directories are named...
7
by: PhilM | last post by:
New to javascript. Is it possible to use javascript to scan a directory client side. If so, could someone point me in the general direction of information on how to. I do not know what keywords I...
10
by: Chris | last post by:
Hi, Not sure if this is the right forum, but hopefully someone can help me. I am creating something for our intranet and i want to list the files and folders of a directory, i found some code...
19
by: SU News Server | last post by:
I've struggled with this for quite a while and I'm am just not sure what is going on. I have the following code import os def buildList( directory='/Users/mkonrad' ) dirs = listing =...
8
by: gil | last post by:
Is it possible to prevent a browser from listing the entire contents of a folder? The site, is hosted on my ISP with the following layout- site/ "user name from ISP" pagefile (dir)...
2
by: ngr | last post by:
I used to use the DirListox control in VB6 but this is no longer supported in VB.NET. What I want to do: I want to take a directory listing and show any subdirectories in a list. When you click...
2
by: Marco Pais | last post by:
Hi there. First of all, sorry for my poor english. I have a problem that I don't know how to resolve. I want to make a dynamic image gallery. With an ASP script, I will read the images from a...
0
by: Steve Hellier | last post by:
Hi, I have 1 solution with 2 projects (ClassLibraray1 - which currently have 6 images embedded in a resource file and WinFormApp1 - which has a picturebox and a listbox) I'm trying to display...
0
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
0
BarryA
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...
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...

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.