Listing Images in a List Box

  • Thread starter Thread starter James Kunicki
  • Start date Start date
J

James Kunicki

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
 
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
 
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
 
* "James Kunicki said:
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?
 
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.
 
Back
Top