如何使文本框始终显示变量值

时间:2011-06-13 00:30:02

标签: .net windows vb.net textbox

我如何让txbroot始终显示root的值,因为目前我仍会显示当前目录(这是在VB.net 2010中)

Private Sub btnrootbrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnrootbwse.Click
        ' Creates a FolderBrowserDialog object
        Dim fbdroot As New FolderBrowserDialog
        'Dialog
        With fbdroot
            ' Desktop is the root folder in the dialog.
            .RootFolder = Environment.SpecialFolder.Desktop
            ' Select the C:\Windows directory on entry.
            .SelectedPath = CurDir()
            ' Prompt the user with a custom message.
            .Description = "Please Select Root Of Sever"
            root = .SelectedPath
            If .ShowDialog = DialogResult.OK Then
                txbroot.Text = root
            End If
        End With
    End Sub

1 个答案:

答案 0 :(得分:1)

应该在ShowDialog

之后执行root做法
If .ShowDialog = DialogResult.OK Then
    root = .SelectedPath
    txbroot.Text = root
End If