【问题标题】:How to make a text box always display a variables value如何使文本框始终显示变量值
【发布时间】:2011-06-13 00:30:02
【问题描述】:

如何让 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

【问题讨论】:

  • 不明白你到底想要什么
  • 基本上,问题是当代码运行并且 txbroot.text 在 root 被对话框更改之前设置。这意味着txbroot中显示的文本是当前目录而不是用户选择的目录

标签: .net windows vb.net textbox


【解决方案1】:

在ShowDialog之后进行root做作

If .ShowDialog = DialogResult.OK Then
    root = .SelectedPath
    txbroot.Text = root
End If

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-20
    • 1970-01-01
    • 2012-07-02
    • 2019-06-29
    • 2021-01-21
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多