473,508 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiselect problem with listbox

Hello,
I have openfiledialog control named "openfileplaylist" and multi-
selectpropert is TRUE. But although i select more than one files using
"shift+arrows", i only get one file listed in my listbox.

What's wrong?

Code:

If openfileplaylist.ShowDialog() = Windows.Forms.DialogResult.OK Then

ListBox1.Items.Add(System.IO.Path.GetFileName(open fileplaylist.FileName))

Else

Sep 26 '07 #1
5 2284
kimiraikkonen,

Did you look in the online help for the openfiledialog's MultiSelect
property? The online help clearly explains that the selected filenames are
returned in the openfiledialog's FileNames property.

The FileNames property is an array of strings. Each element of the array is
one of the selected filenames.

One option would be to loop through the FileNames array, adding each
filename to the listbox:

For Each f As String In openfileplaylist.FileNames
ListBox1.Items.Add(System.IO.Path.GetFileName(f))
Next

Kerry Moorman

"kimiraikkonen" wrote:
Hello,
I have openfiledialog control named "openfileplaylist" and multi-
selectpropert is TRUE. But although i select more than one files using
"shift+arrows", i only get one file listed in my listbox.

What's wrong?

Code:

If openfileplaylist.ShowDialog() = Windows.Forms.DialogResult.OK Then

ListBox1.Items.Add(System.IO.Path.GetFileName(open fileplaylist.FileName))

Else

Sep 26 '07 #2
On Sep 27, 1:56 am, Kerry Moorman
<KerryMoor...@discussions.microsoft.comwrote:
kimiraikkonen,

Did you look in the online help for the openfiledialog's MultiSelect
property? The online help clearly explains that the selected filenames are
returned in the openfiledialog's FileNames property.

The FileNames property is an array of strings. Each element of the array is
one of the selected filenames.

One option would be to loop through the FileNames array, adding each
filename to the listbox:

For Each f As String In openfileplaylist.FileNames
ListBox1.Items.Add(System.IO.Path.GetFileName(f))
Next

Kerry Moorman

"kimiraikkonen" wrote:
Hello,
I have openfiledialog control named "openfileplaylist" and multi-
selectpropert is TRUE. But although i select more than one files using
"shift+arrows", i only get one file listed in my listbox.
What's wrong?
Code:
If openfileplaylist.ShowDialog() = Windows.Forms.DialogResult.OK Then
ListBox1.Items.Add(System.IO.Path.GetFileName(open fileplaylist.FileName))
Else- Hide quoted text -

- Show quoted text -
Mr. Moorman,
Very thanks. It worked!

Sep 27 '07 #3
But also i want to ask this, how could be the code that inserts the
"full path" of each files (multi-selection) into listbox1 instead of
only filenames?

Thanks.

Sep 27 '07 #4
kimiraikkonen,

I think the FileNames array contains the full path, so in that case you
would not want to use the GetFileName method:

For Each f As String In openfileplaylist.FileNames
ListBox1.Items.Add(f)
Next

Kerry Moorman

"kimiraikkonen" wrote:
But also i want to ask this, how could be the code that inserts the
"full path" of each files (multi-selection) into listbox1 instead of
only filenames?

Thanks.

Sep 27 '07 #5
On Sep 28, 1:22 am, Kerry Moorman
<KerryMoor...@discussions.microsoft.comwrote:
kimiraikkonen,

I think the FileNames array contains the full path, so in that case you
would not want to use the GetFileName method:

For Each f As String In openfileplaylist.FileNames
ListBox1.Items.Add(f)
Next

Kerry Moorman

"kimiraikkonen" wrote:
But also i want to ask this, how could be the code that inserts the
"full path" of each files (multi-selection) into listbox1 instead of
only filenames?
Thanks.- Hide quoted text -

- Show quoted text -
Mr. Moorman,
You "really" helped. Thanks for the advice. Here's my second 5-star
rating for you.

Thanks.

Sep 28 '07 #6

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

Similar topics

2
6350
by: Sally | last post by:
I have a simple multiselect listbox with a rowsorce of MemberID, MemberName, SendLetter. SendLetter is a Yes/No field. What is the code to set SendLetter to Yes when the user selects MemberName? I...
2
3334
by: Cassie Pennington | last post by:
I am trying to write various items from a multiselect list box to an SQL statement to update a report, without success. SQL only appears to accept hard-coded data or control values from a form, not...
2
6056
by: Alan Lane | last post by:
Hello world: I'm using Access 2003. I have 2 listboxes. One is a single column. The other has two columns. I can use Dev Ashish's code (thanks Dev!) from the Access MVP Website to accumulate...
2
7937
by: Peder Y | last post by:
Anyone knows if there is some kind of property or function that will return the last selected/deselected item/index in a multiselect ListBox? SelectedIndex will point to first index in the...
6
1694
by: ¿ Mahesh Kumar | last post by:
Hi groups, Control name : ListboxID (lstCertification), selection mode=mutliselect. On Pageload i'm assinging string lstSplit="1/3/6/8" of the previously selected listindex id's. Now on the...
2
1943
by: Steph | last post by:
I have created a multiselect list box control (lbx_comorb) that is populated from a datatable (dt_ptAdmission). The list box populates now problem at all. However the issue is when I load the...
2
1579
by: ttime | last post by:
I've got a form that uses a multiselect listbox. When a user is selected from a combo box, values are populated into this listbox associated with that user. The problem is, if one person has say...
3
3612
by: kaosyeti via AccessMonster.com | last post by:
hey... i have an unbound multiselect listbox on a form that i want to use to populate text boxes on that form. so if a user selects the 3rd item in a list of 20, how can i have that item show up...
5
4218
by: martin DH | last post by:
Hello, The details are below, but I have a simple form (Form1) with two objects and a "search" command button. When the two objects are cascading combo boxes (the form creates the parameters for a...
1
1831
by: asharma0001 | last post by:
Hi all, I was wondering whether somebody might be able to help me with a question I have on a MS Access Database I'm building. I have created a search form with a few multiselect listboxes....
0
7224
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
7118
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
7323
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
7493
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
5625
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,...
1
5049
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...
0
3192
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...
0
1550
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 ...
0
415
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...

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.