0

Apologies if this is really simple but I'm fairly new to programming. I've created a program that uses an open dialog box and outputs the names of the file to a textbox.

Where I'm having issues is trying to get the textbox to display more than one line as all it seems to be doing is writing one line in the textbox.

The code I'm using is below, could someone please advise what I need to change so that I can get this to work.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click    
    Dim strFileName As String

    OpenFD.Multiselect = True
    OpenFD.InitialDirectory = "\\server\filename\"
    OpenFD.Title = "Open a Text File"
    OpenFD.Filter = "Text Files(.txt)|*.txt"
    Dim DidWork As Integer = OpenFD.ShowDialog()
    strFileName = OpenFD.FileName


    If DidWork = DialogResult.Cancel Then

        MsgBox("Cancel Button Clicked")

    Else

        strFileName = OpenFD.FileName
        TextBox1.Text = strFileName += 1

    End If
End Sub

I've managed to get everything else to work correctly but it's just this one thing.

4

2 回答 2

1
Dim strFileName() As String

'...

Dim DidWork As Integer = OpenFD.ShowDialog()

If DidWork = DialogResult.Cancel Then
    MsgBox("Cancel Button Clicked")
Else
    strFileName = OpenFD.FileNames
    TextBox1.Multiline = True
    TextBox1.Text = ""

    For Each sFile as String in strFileName
        TextBox1.Text &= sFile & System.Enviroment.NewLine()
    Next
End If
于 2013-02-04T11:00:11.953 回答
0

TextBox.Multiline属性设置为True

于 2013-02-04T10:49:39.050 回答