I was able to get the ComboBox to load a list of files from a directory.
but, now i am trying to get the contents of that file output to a TextBox or richTextBox.

I am able to use this to output to another ComboBox(however, this is not what i need...):
//code for codebox to codeBox output

string[] files = System.IO.Directory.GetFiles(@"c:\scripts");

        string[] lineOfContents = File.ReadAllLines(comboBox1.Text);
        foreach (var line in lineOfContents)
            string[] tokens = line.Split(',');
            //end of codebox to codebox output.

However, I can't get the entire file to go to a Textbox.
When i use <this.richTextBox1.Text = comboBox2.Text;>
it only pulls the selected line of th text from the combobox and doesnt pull all lines of the .TXT as its split into seperate lines.

Summary: I cant seem to to pull all Lines of text from the textfile listed within the combobox into a Richtextbox by using the combobox to retrieve the list of files first.

  • am I making this too complicated and just missing something very simple??

I can use radio buttons to push the contents of the file to the RichTextBox.... something about loading from combobox to TextBox is not working.

Thank you in Advance!!!


2 Years
Discussion Span
Last Post by Joseph_18

It looks like you need to use the AppendText method of the TextBox class:

        foreach(string line in File.ReadAllLines(comboBox1.Text))

Hi Tinstaafl, i look forward to plugging this in when i get back home. Thank you very much for your response and time taken to answer my question!

I will update soon.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.