Domanda

When I use an OpenFileDialog, and select a file and click open etc, etc...

I want a label on the same form to automatically update with the directory path. At the moment I have this working, However the label updates on click, not automatically on the directory change.

CODE:

Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click

    Label4.Text = OpenFileDialog2.FileName

End Sub

Cna I change the "Label4_Click" to something else for an auto update?

È stato utile?

Soluzione

How are you displaying the OpenFileDialog? You need to update the Label from there!...

Something like:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    If OpenFileDialog2.ShowDialog = Windows.Forms.DialogResult.OK Then
        Label4.Text = OpenFileDialog2.FileName
    End If
End Sub
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top