Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Enabling and Disabling text boxes

Enabling and Disabling text boxes

Scheduled Pinned Locked Moved Visual Basic
tutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ibok23
    wrote on last edited by
    #1

    I am trying to write a code for enabling and disabling a textboxes for output and for input during certain times in the program. One of my textboxes is PartNumber.text. At the beginning of the program I want to disable this box; however, if they want to add another Part this box will become clear so they can input a number so I want it to be enabled. I am confused on how to write it. Thank you, ibok23

    D 1 Reply Last reply
    0
    • I ibok23

      I am trying to write a code for enabling and disabling a textboxes for output and for input during certain times in the program. One of my textboxes is PartNumber.text. At the beginning of the program I want to disable this box; however, if they want to add another Part this box will become clear so they can input a number so I want it to be enabled. I am confused on how to write it. Thank you, ibok23

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You use the Enabled property of the TextBox control. When to enable it and disable it depends on your design. If I remember right, you were using menus to do Add, Delete, ... If the Click handler of the Add MenuItem, you would use something like this:

      Private Sub mnuAdd\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAdd.Click
          **txtPartNumberTextBox.Enabled = True**
          ... the rest of your code to enable controls and buttons goes here ...
      End Sub
      

      The user would have to click some button you have on your form to tell your app that all the data is entered and to process it to add it to a database. This button has a Click handler. This is where you would disable the textboxes and buttons you need to:

      Private Sub btnAddData\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddData.Click
          **txtPartNumberTextBox.Enabled = False**
          ... the rest of your code to disable controls and buttons goes here ...
          ... also the code to process the data to add goes here...
      End Sub
      

      RageInTheMachine9532

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups