Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Textbox Readonly

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2007, 07:15 AM
Junior Member
 
Join Date: Jun 2007
Posts: 17
Default Textbox Readonly

Is it possible to make a Multiline Textbox control readonly so that the user cannot change the contents?
Reply With Quote
  #2 (permalink)  
Old 06-29-2007, 07:31 AM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Ioannina, Greece
Posts: 356
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Catch KeyPressed event and use IgnoreKey

Code:
<font size="2"><font color="#0000ff">Sub </font></font><font size="2">TextBox1_KeyPress (key)</font>
<font size=
"2">textbox1.IgnoreKey</font>
<font size=
"2"><font color="#0000ff">End Sub</font></font>
Now only DEL key can change TextBox1.Text
But if you catch LostFocus event too, you can restore it's value again
__________________
Dimitris Zacharakis
http://www.terracom.gr
Reply With Quote
  #3 (permalink)  
Old 06-29-2007, 07:44 AM
Junior Member
 
Join Date: Jun 2007
Posts: 17
Default Textbox Readonly

Excellent works great....

Thanks
Reply With Quote
  #4 (permalink)  
Old 06-29-2007, 10:10 AM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
Awards Showcase
Beta Tester 
Total Awards: 1
Default

A more simple way is to set the Enabled property to False but still make the textbox visible.
The downside is that it will be slightly greyed out.

Regards,
RandomCoder
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #5 (permalink)  
Old 08-20-2007, 03:42 AM
Junior Member
 
Join Date: Aug 2007
Location: México.
Posts: 36
Default An example? Please...

Hi!
Can you give me an example?

Quote:
But if you catch LostFocus event too, you can restore it's value again
If I have 2 forms, each one with a TextBox, and the text is changed with DEL key;
How to restore the original value of the textbox after having changed one form to other one?

Catch LostFocus event using Refresh?

Thanks for your responses.
Attached Files
File Type: sbp demo.sbp (764 Bytes, 16 views)
Reply With Quote
  #6 (permalink)  
Old 08-20-2007, 03:46 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 1,057
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Hi kyto,

I attached a simple demo2.

If textbox1 gets the focus, the actual value is stored in a global variable. You don't need this, if you have already stored the textbox value in another variable in your appliction.
Change the value of the textbox and click on one of the other controls or somewhere at the main form. Now the lost focus event restores the original value of the textbox.


specci48
Attached Files
File Type: sbp demo2.sbp (936 Bytes, 23 views)
Reply With Quote
  #7 (permalink)  
Old 08-20-2007, 07:28 PM
Junior Member
 
Join Date: Aug 2007
Location: México.
Posts: 36
Default Thanks!

Thanks Specci48!
This is what I needed.
Reply With Quote
  #8 (permalink)  
Old 08-20-2007, 07:36 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

I really don't get it...

Why use a Textbox to show un-editable text??

Isn't that what label are supposed to do?
Is it because of the border around the textbox that the Label don't have??
In that case put a panel slightly larger than the label, under the label, in order tore-create that effect...
With a bonus of not beeing editale, so your text is safe...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #9 (permalink)  
Old 08-20-2007, 08:36 PM
Junior Member
 
Join Date: Aug 2007
Location: México.
Posts: 36
Default Good solution.

I had not thought about that, it looks like to me a good solution, for what also I will try it.

Thanks Cableguy!
Reply With Quote
  #10 (permalink)  
Old 08-20-2007, 08:38 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 1,057
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Just naming two differences between a label and a (not editable) textbox:

1. a textbox adds scrolbars if needed so you can show much more text an a much smaller space of a form (or panel).

2. if you want to show an unknown (large) text in a label, you probably will get into the problem of the linebreaking on the device (http://www.basic4ppc.com/forum/questions-windows-mobile/616-different-behavior-desk-ppc.html)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox with ReadOnly,IgnoreKey,TextAlignment Filippo Basic4ppc Wishlist 0 11-17-2007 08:23 PM
Readonly property in the Textbox control bidibulle Basic4ppc Wishlist 14 11-16-2007 08:19 AM
Can ComboBox be setted as readonly? blackiice Questions (Windows Mobile) 4 10-24-2007 03:15 PM


All times are GMT. The time now is 10:23 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0