Text To Listbox

There are ocassions when a list box control needs to be populated with text for subsequent viewing.

The following code snippet will accomplish the desired task.

[codesyntax lang=”cpp”]

void psdUTilFrame::fileToLB(string inf, wxListBox * lb)
{
    lb->Clear();
    wxTextFile flf;
    wxString infle = inf;
    flf.Open(infle);
    for ( wxString str = flf.GetFirstLine(); !flf.Eof(); str = flf.GetNextLine() )
    {
        lb->Append(str);

    }
}

[/codesyntax]

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

Leave a Reply

Your email address will not be published. Required fields are marked *