Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 784555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:43:55+00:00 2026-05-14T20:43:55+00:00

Please allow me to explain what I have and what I am trying to

  • 0

Please allow me to explain what I have and what I am trying to achieve.

I have a textbox (called txtb1) and a button under it (called btn_browse) on a winform in a vb.net project.

When the user clicks the button a folder browser dialog appears. The user selects his desired folder and when he/she clicks ‘ok’ the dialog closes and the path of the folder selected appears in the textbox. I also want to store that value in a variable to be used somewhere else(the value will be copied to an xml file when the user clicks ‘apply’ on the form, but this has no effect nor is related to my problem).

To achieve that I have the following code:

Public myVar As String
Private Sub btn_browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_browse.Click

    Dim f As New FolderBrowserDialog
    If f.ShowDialog() = DialogResult.OK Then
        txtb1.Text = f.SelectedPath
    End If
    myVar = txtb1.text
    f.Dispose()

End Sub

This part works with no problems.

Now, what if the user either:
1- decides to enter the path manually rather than use the browse button. or,
2- after using the browse button and selecting the folder they decide to manually change the location

In trying to solve this I added a textchanged event to the textbox as follows:

Private Sub txtb1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtb1.TextChanged
    myVar = txtb1.Text

End Sub

However, this is not working. Apparently, and I don’t know if this is relevant, when the user selects the desired folder using the browse button the textchanged event is also triggered. and when I click on the textbox (to give it focus) and press any keyboard key the application simply stops responding.

So my questions are: am I going about this the right way? if my logic is flawed, could someone point me to how usually such a thing could be achieved? is it possible to limit the triggering events to only keyboard input as a way around this? I tried the keydown and keypress events but I am getting the freeze.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:43:55+00:00Added an answer on May 14, 2026 at 8:43 pm

    Set the TextBox.ReadOnly property to true and then set the backcolor to white and forecolor to black to look like a normal textbox but they can’t edit it.

    Then you have no need to worry about handling any events from the textbox like u are doing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please allow me to explain what I am trying to do - I think
I am developing LiveJournal.com client and i have one question. Can u, please, explain
I'm trying to write a log file from an ASP.NET application under IIS7, but
Please allow me to preface this by saying I'm pretty much brand new to
To keep things simple, please allow the assumption that some code requires the use
I am a newbie in cmd, so please allow me to ask a stupid
please have a look at the following code import java.util.ArrayList; import java.util.List; public class
Please see demo here: http://jsfiddle.net/mA6qm/1/ (expand console) Why aren't events being sent or received
Here is a hard one I have been trying to get it work. It
Hopefully I can explain this well enough, but please let me know if more

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.