0

I am currently trying to make a ListBox its values from a text file - values.txt

The values.txt file contains a different value on each line e.g.

Value1
Value 2
Value3
Value 4

How could I use the values in this text file to be used within the ListBox?

1

1 Answer 1

3

Well, first read the text using either StreamReader or File.ReadAllLines.
Then, add the data to your ListBox.
Example:

listBox1.Items.AddRange(File.ReadAllLines(@"C:\file.txt"));

It should work.

Sign up to request clarification or add additional context in comments.

1 Comment

James Make sure to accept answers to your comments :) other wise you may not get replies to youre future questions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.