Readonly property in the Textbox control

bidibulle

Member
Licensed User
Hi,

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

--
Pierre
 

specci48

Well-Known Member
Licensed User
As a "workaround", set TextBox.Enabled = False, or uncheck the enabled checkbox directly in the form editor.
 

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:

B4X:
Sub Textbox1_KeyPress (key)
   Textbox1.IgnoreKey
End Sub
Textbox is enabled but you can't write anything inside.
 

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.
 

agraham

Expert
Licensed User
I tested it. It works but it's not perfect.
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!
 

Attachments

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:

agraham

Expert
Licensed User
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:
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.
 

Filippo

Expert
Licensed User
hi,

here is my TextBoxReadOnly

Ciao,
Filippo
 

Attachments

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

B4X:
Sub Globals
   'Declare the global variables here.
 End Sub

Sub App_Start
  Form1.Show
End Sub

Sub cmdShow_Click
  txtReadOnly.Text=txtReadWrite.Text
End Sub

Sub txtReadonly_GotFocus
   txtReadWrite.Focus
End Sub
 

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.;)
 

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.
 

agraham

Expert
Licensed User
You have not understood mine code! It should be only one beispiel like a text box readonly can become.;)
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.
 

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 TextBoxEx.zip
View attachment TextBoxEx example.zip
 

alfcen

Well-Known Member
Licensed User
Gentlemen, these Textbox properties definitely belong into the IDE :)
What do you think, Erel?
 
Top