Readonly property in the Textbox control

Discussion in 'Basic4ppc Wishlist' started by bidibulle, Nov 7, 2007.

  1. bidibulle

    bidibulle Member Licensed User


    Is it possible to add the readonly property to the textbox control?
    It exist in VS2005.

  2. specci48

    specci48 Well-Known Member Licensed User

    As a "workaround", set TextBox.Enabled = False, or uncheck the enabled checkbox directly in the form editor.
  3. Nkieto

    Nkieto Member Licensed User

    Problem with TextBox.Enabled = False or unchecking the enabled checkbox directly in the form editor is that textbox font color change to grey.

    What you can do is leaving Textbox enabled and add this method:

    Sub Textbox1_KeyPress (key)
    End Sub
    Textbox is enabled but you can't write anything inside.
  4. bidibulle

    bidibulle Member Licensed User

    Thanks Nkieto for the tips.
    I tested it. It works but it's not perfect.

    For the moment I will use it but if Erel can add the property in the next version it will be great.

    Anyway thanks for the support and thanks Erel for this great tool.
  5. agraham

    agraham Expert Licensed User

    In what way? I tried it and it seems to feel the same to the user as setting the ReadOnly property.

    If you want to access properties not exposed by B4PPC and you have SharpDevelop or VS2003 or VS2005 you can always knock up a small library like the one attached.

    More generally to everyone else - after installing .NET 1.1 to get version 5.80 to compile I now "appear" to be able to target .Net 1.0 for the device with VS2005. I had assumed that I would need to install the whole .NET 1.1 SDK. Can somebody who only has .NET 1.0 on their device try this for me please!

    Attached Files:

  6. taximania

    taximania Well-Known Member Licensed User

    Hi agraham.

    Had a little play with your code. Attatched.

    On the Desktop.
    When ReadOnlyTextBox.ReadOnly = 'True or False' the textbox remains white and the text is black.

    On my Device.
    When ReadOnlyTextBox.ReadOnly = True the entire texbox is gray and the text is black.

    When TextBox2.Enabled = False, the textbox remains white and the text is gray on both Desktop and Device.

    Not sure if this is a useless post. It was just an observation.

    What I do know is that if I start a new #Sharp project and use your code, It will compile and run on the Desktop, but not my device :sign0148:
    Last edited: Nov 10, 2007
  7. agraham

    agraham Expert Licensed User

    It was a quickly knocked up to test a point and the reference to System.Text is not needed. However even with that the dll I compiled works on my device.

    Are you sure that your compilation is really targeting the device? I don't know SharpDevelop but I believe that it is easy to change the target by a menu option somewhere.
  8. Filippo

    Filippo Expert Licensed User


    here is my TextBoxReadOnly


    Attached Files:

  9. agraham

    agraham Expert Licensed User

    I am afraid your code is dangerous - you are adding an events every time the textbox gets the focus and the user can still select the text box. Try this

    Sub Globals
    'Declare the global variables here.
     End Sub

    Sub App_Start
    End Sub

    Sub cmdShow_Click
    End Sub

    Sub txtReadonly_GotFocus
    End Sub
  10. Filippo

    Filippo Expert Licensed User

    Hallo agraham,

    You have not understood mine code! It should be only one beispiel like a text box readonly can become.;)
  11. bidibulle

    bidibulle Member Licensed User

    I prefer the DLL solution.

    With "Textbox1.IgnoreKey" you can select the text and delete the text :)

    I will try to improve the DLL to more property.
  12. agraham

    agraham Expert Licensed User

    Sorry Filippo but I am correct. I've run it in the IDE with a breakpoint on "AddEvent (objTextbox ,"KeyPress", "goIgnorekey")" in Sub ConvertTextboxToLabel(objTextbox) and every time you move the focus to txtReadWrite and then back to txtReadonly this statement is executed.
  13. bidibulle

    bidibulle Member Licensed User

    I improved the DLL and I changed the name.
    TextboxEx added the following property to the textbox:
    - ReadOnly : Readonly property
    - Maxlength : Maximum characters in the textbox
    - bsNone : No border
    - bsSingle : Single border
    - bs3D : 3D border

    I try to add the 'Textalign' property but it didn't work in the PPC :-(

    I attached the Sharpdevelop project and an example.

    View attachment
    View attachment TextBoxEx
  14. alfcen

    alfcen Well-Known Member Licensed User

    Gentlemen, these Textbox properties definitely belong into the IDE :)
    What do you think, Erel?
  15. Erel

    Erel Administrator Staff Member Licensed User

    I would consider it adding to Basic4ppc internal textbox.
    BTW, you can use FormLib to change the alignment.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice