muffintwinkly
asked on
displaying file order in a listbox
Hi,
I am using a button and a listbox in my winform.
When I click the button, a user can select multiple files at the same time.
However, always the last selected file goes to the top of the list in the listbox.
how can I list the files in the listbox in order to be selected? For example, if I select the 3 doc files with following order:1.doc, 2.doc and 3.doc, and add all of them at the same time, the list of file should be displayed as 1.doc, 2.doc, and 3.doc from top to bottom.
The following codes are for the button.
private void button1_Click_1(object sender, EventArgs e)
{
dlg.Multiselect = true;
if (dlg.ShowDialog() == DialogResult.OK)
{
foreach (string fileName in dlg.FileNames)
{
textBox1.Text = fileName;
listBox1.Items.Add(Path.Ge tFileName( textBox1.T ext));
}
}
}
I am using a button and a listbox in my winform.
When I click the button, a user can select multiple files at the same time.
However, always the last selected file goes to the top of the list in the listbox.
how can I list the files in the listbox in order to be selected? For example, if I select the 3 doc files with following order:1.doc, 2.doc and 3.doc, and add all of them at the same time, the list of file should be displayed as 1.doc, 2.doc, and 3.doc from top to bottom.
The following codes are for the button.
private void button1_Click_1(object sender, EventArgs e)
{
dlg.Multiselect = true;
if (dlg.ShowDialog() == DialogResult.OK)
{
foreach (string fileName in dlg.FileNames)
{
textBox1.Text = fileName;
listBox1.Items.Add(Path.Ge
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER