Hi there,
I'm just starting at VB.NET (all VB come to that), and have what's probably
a very basic question:
I have a form in Visual Studio 2003 that has a listbox that is meant to be
populated with file names from the OpenFileDialog method (see below). The
problem is that if you select, say three files in the Open File dialogue
box, the listbox is populated with three of the same file rather than three
different files.
Any clues on where I'm going wrong?
Many thanks
John
Private Sub button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim openFileDialog1 As New OpenFileDialog
Dim fName As String
openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True
openFileDialog1.Multiselect = True
If openFileDialog1.ShowDialog() = DialogResult.OK Then
For Each fName In openFileDialog1.FileNames
lstWrkFiles.Items.Add(openFileDialog1.FileName)
Next
End If
End Sub 4 17356
John,
In your For Each loop:
lstWrkFiles.Items.Add(fName)
Kerry Moorman
"John" wrote: Hi there,
I'm just starting at VB.NET (all VB come to that), and have what's probably a very basic question:
I have a form in Visual Studio 2003 that has a listbox that is meant to be populated with file names from the OpenFileDialog method (see below). The problem is that if you select, say three files in the Open File dialogue box, the listbox is populated with three of the same file rather than three different files.
Any clues on where I'm going wrong?
Many thanks
John
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim openFileDialog1 As New OpenFileDialog
Dim fName As String openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True
openFileDialog1.Multiselect = True If openFileDialog1.ShowDialog() = DialogResult.OK Then
For Each fName In openFileDialog1.FileNames
lstWrkFiles.Items.Add(openFileDialog1.FileName)
Next End If
End Sub
That's great. Thanks very much Kerry.
Seems obvious now you point it out!
John
"Kerry Moorman" <Ke**********@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com... John,
In your For Each loop:
lstWrkFiles.Items.Add(fName)
Kerry Moorman
"John" wrote:
Hi there,
I'm just starting at VB.NET (all VB come to that), and have what's probably a very basic question:
I have a form in Visual Studio 2003 that has a listbox that is meant to be populated with file names from the OpenFileDialog method (see below). The problem is that if you select, say three files in the Open File dialogue box, the listbox is populated with three of the same file rather than three different files.
Any clues on where I'm going wrong?
Many thanks
John
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim openFileDialog1 As New OpenFileDialog
Dim fName As String openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True
openFileDialog1.Multiselect = True If openFileDialog1.ShowDialog() = DialogResult.OK Then
For Each fName In openFileDialog1.FileNames
lstWrkFiles.Items.Add(openFileDialog1.FileName)
Next End If
End Sub
John,
In your For Each loop:
lstWrkFiles.Items.Add(fName)
Kerry Moorman
"John" wrote: Hi there,
I'm just starting at VB.NET (all VB come to that), and have what's probably a very basic question:
I have a form in Visual Studio 2003 that has a listbox that is meant to be populated with file names from the OpenFileDialog method (see below). The problem is that if you select, say three files in the Open File dialogue box, the listbox is populated with three of the same file rather than three different files.
Any clues on where I'm going wrong?
Many thanks
John
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim openFileDialog1 As New OpenFileDialog
Dim fName As String openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True
openFileDialog1.Multiselect = True If openFileDialog1.ShowDialog() = DialogResult.OK Then
For Each fName In openFileDialog1.FileNames
lstWrkFiles.Items.Add(openFileDialog1.FileName)
Next End If
End Sub
That's great. Thanks very much Kerry.
Seems obvious now you point it out!
John
"Kerry Moorman" <Ke**********@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com... John,
In your For Each loop:
lstWrkFiles.Items.Add(fName)
Kerry Moorman
"John" wrote:
Hi there,
I'm just starting at VB.NET (all VB come to that), and have what's probably a very basic question:
I have a form in Visual Studio 2003 that has a listbox that is meant to be populated with file names from the OpenFileDialog method (see below). The problem is that if you select, say three files in the Open File dialogue box, the listbox is populated with three of the same file rather than three different files.
Any clues on where I'm going wrong?
Many thanks
John
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim openFileDialog1 As New OpenFileDialog
Dim fName As String openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True
openFileDialog1.Multiselect = True If openFileDialog1.ShowDialog() = DialogResult.OK Then
For Each fName In openFileDialog1.FileNames
lstWrkFiles.Items.Add(openFileDialog1.FileName)
Next End If
End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: james.dixon |
last post by:
Hi
I was wondering if anyone else had had this problem before (can't find
anything on the web about it).
I have three select elements (list boxes - from here on I'll refer to
them as 'the...
|
by: Chris Jones |
last post by:
Does anyone know of a C#/ASP.NET Open File dialog that I can use in an
aspx page that allows multiselect? I need to be able to select and upload
numerous files.
Is there a reason why MS has made...
|
by: Olaf Baeyens |
last post by:
In .NET v1.1 I am trying to select multiple files using OpenFileDialog like
this
OpenFileDialog openFileDialog=new OpenFileDialog();
openFileDialog.Multiselect=true;
i...
|
by: Jay |
last post by:
Hi All,
My users are complaining about the page refreshing when they are
selecting multiple rows in a datagrid. Has anyone tried to manage this
using javascript?
I tried smartnavigation but that...
|
by: sneha123 |
last post by:
There will be some 20 questions and for each question there will be 4
choices.what i want to do is to select multiple answers by clicking the
checkbox. i m using asp.net,vb.net
pls help me
we...
|
by: Bob Loveshade |
last post by:
I am looking for an example that shows how to select and highlight
multiple rows in a DataGrid.
My DataGrid is part of a Web User Control which is contained in an ASPX
page.
I haven't been...
|
by: John |
last post by:
Hi there,
I'm just starting at VB.NET (all VB come to that), and have what's probably
a very basic question:
I have a form in Visual Studio 2003 that has a listbox that is meant to be...
|
by: areef.islam |
last post by:
Hi, I am kinda new to javascript and I am having this problem with
selecting multiple options from a select tag. Hope someone can help me
out here.
here is my code...
|
by: junaid |
last post by:
Hi,
please help me
i want to select multiple files including directories using
OpenFileDialog,
but i cant get directory name(s) in FileNames property
i am using J#, VS2005
are there any method...
|
by: TjFL |
last post by:
I have a form where specific external files are selected by the user depending on needs. Each item listed on the form has 4 Yes/No boxes next to it where they select what they want. The result will...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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: 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...
|
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,...
| |