Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8279713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:25:00+00:00 2026-06-08T09:25:00+00:00

So, I had to use a Listbox for a small C# project, and ran

  • 0

So, I had to use a Listbox for a small C# project, and ran into a problem. The Listbox displays file-names, and an item is added every-time someone uses a File Dialog box to add in the item. The problem is when the very first file is added, nothing shows up. but when a second file is added, its an empty line.

Here is a picture to illustrate the problem:

The problem with the listbox

Now, how do I get rid of the first blank line and properly add in the filename to the top of the listbox?

Here is the code that I am using to add to the listbox.

// Set a global variable to hold all the selected files result
List<String> fullFileName;

private void addBtn_Click(object sender, EventArgs e)
{
    DialogResult result = fileDialog.ShowDialog(); // Show the dialog.
    if (result == DialogResult.OK) // Test result.
    {
       // put the selected result in the global variables
       fullFileName = new List<String>(fileDialog.FileNames);
       // add just the names to the listbox
       foreach (string fileName in fullFileName)
       {
           dllBox.Items.Add(fileName.Substring(fileName.LastIndexOf(@"\") + 1));
       }
   }
}

And here is the properties for fileDialog:

FileDialog

As well as the dllBox properties

1a1s 21

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:25:01+00:00Added an answer on June 8, 2026 at 9:25 am

    Try changing your DrawMode to Normal rather than OwnerDrawFixed in the listbox properties.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had use listbox.itemsource as my e.Result. <ListBox Height=476 HorizontalAlignment=Left Margin=11,17,0,0 Name=ListBox1 VerticalAlignment=Top Width=434
How to Remove Badge from the tabbar item i had use below code but
it’s been a while since the last time I had to use regex, I
I ran into a bind whereby I had to sort the data read from
I just had a use case where I needed to split a list into
Suppose I have had to use git filter-branch to remove a file from revision
I had to use json2.js in my project as browser(IE8) JSON object was not
i had use the spring3.1 ibatis2.x and mysql5.5. then i wanna use the replication
I had created one HTML page for my experiance. In this i had use
I have been frustrated that I have had to use the very buggy XCode

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.