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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. To make characters in the text of TextBox ReadOnly.

To make characters in the text of TextBox ReadOnly.

Scheduled Pinned Locked Moved Visual Basic
csharpquestion
5 Posts 4 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.
  • P Offline
    P Offline
    Prodigy201
    wrote on last edited by
    #1

    Hi All !! I am new to VB.NET... I want to make the characters in the text of TextBox control read only... That is, those characters should not be replaced by any other character, or can not be editable... So is there any property or method that can be implemented to the charactres/text(string) of textbox's text ?? Well, very clearly, I don't want to make the whole Textbox uneditable. I just want some part of input and moreover already set text in the textbox uneditable, as we can see as par as in MaskedTextBox, for e.g. in date format, we have "/" separator uneditable. So I just want to make the text uneditable. Expecting the responses.:) Thanks, Prodigy201

    K D S 3 Replies Last reply
    0
    • P Prodigy201

      Hi All !! I am new to VB.NET... I want to make the characters in the text of TextBox control read only... That is, those characters should not be replaced by any other character, or can not be editable... So is there any property or method that can be implemented to the charactres/text(string) of textbox's text ?? Well, very clearly, I don't want to make the whole Textbox uneditable. I just want some part of input and moreover already set text in the textbox uneditable, as we can see as par as in MaskedTextBox, for e.g. in date format, we have "/" separator uneditable. So I just want to make the text uneditable. Expecting the responses.:) Thanks, Prodigy201

      K Offline
      K Offline
      kyosugi
      wrote on last edited by
      #2

      my 1 i used the property table of the textbox scroll and go find the read-only option n set it to true

      P 1 Reply Last reply
      0
      • K kyosugi

        my 1 i used the property table of the textbox scroll and go find the read-only option n set it to true

        P Offline
        P Offline
        Prodigy201
        wrote on last edited by
        #3

        Hi !! Thanks for the response ! Well, I don't want to make whole textbox control as readonly, but I just want to make some part of text in the textbox readonly, i.e to make some part of the text uneditable, as we can find it in MaskedTextBox control. for e.g. "/" separator in date format (found in mask properties of MaskedTextBox) as uneditable character. So is there any property or method that can be used to make this functionality? Expecting response :) Thanks, Prodigy201

        1 Reply Last reply
        0
        • P Prodigy201

          Hi All !! I am new to VB.NET... I want to make the characters in the text of TextBox control read only... That is, those characters should not be replaced by any other character, or can not be editable... So is there any property or method that can be implemented to the charactres/text(string) of textbox's text ?? Well, very clearly, I don't want to make the whole Textbox uneditable. I just want some part of input and moreover already set text in the textbox uneditable, as we can see as par as in MaskedTextBox, for e.g. in date format, we have "/" separator uneditable. So I just want to make the text uneditable. Expecting the responses.:) Thanks, Prodigy201

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

          There is no property in the TextBOx that will do this for you. You'll either have to use the MaskedTextBox control to get what you want (easiest option), or create your own version of the control (much more difficult).

          Dave Kreskowiak Microsoft MVP - Visual Basic

          1 Reply Last reply
          0
          • P Prodigy201

            Hi All !! I am new to VB.NET... I want to make the characters in the text of TextBox control read only... That is, those characters should not be replaced by any other character, or can not be editable... So is there any property or method that can be implemented to the charactres/text(string) of textbox's text ?? Well, very clearly, I don't want to make the whole Textbox uneditable. I just want some part of input and moreover already set text in the textbox uneditable, as we can see as par as in MaskedTextBox, for e.g. in date format, we have "/" separator uneditable. So I just want to make the text uneditable. Expecting the responses.:) Thanks, Prodigy201

            S Offline
            S Offline
            Stephen McGuire
            wrote on last edited by
            #5

            You can use the KeyPress event of your textbox field to override the characters that are entered, forcing the character at a certain position in the string to be a particular character. You can also limit the number of characters enetered. The following example is for a date entry field: With YourTextBox If Len(.Text) >= 10 And Not e.KeyChar = ChrW(8) Then MsgBox("Maximum number of input characters is 10!", _ MsgBoxStyle.Information, "Invalid Data Input") Exit Sub ElseIf Len(.Text) = 2 And Not e.KeyChar = ChrW(8) And Not e.KeyChar = ChrW(47) Then .Text = .Text & "/" .Select(.Text.Length, 0) ElseIf Len(.Text) = 5 And Not e.KeyChar = ChrW(8) And Not e.KeyChar = ChrW(47) Then .Text = .Text & "/" .Select(.Text.Length, 0) Else End If End With I use something similar to this to validate entry on all my fields. It is used in combination with the TextChanged and Validating events. I have stripped out code for setting errorproviders etc.. Steve

            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