Re: How to make TextBox read only but look normal
- Posted by DerekParnell (admin) Jul 06, 2009
- 1362 views
At the moment in my program, when a record is in display mode I set the TextBox's to setEnabled(TXTBox,False) but this makes everything grey & looks yuk.
How might I better display the fields and prevent people from changing the contents. But then enable the fields after clicking the edit button.
Firstly, the user interface needs to give the user a visual clue when a field is enabled or not. If you don't like the default disabled colours, you can set the background color for it. With the current win342lib in the sourceforge respository, you can call ...
setDisableBg( TXTBox, Brown) -- or any other color you like.
This is the background colour that the text control gets when it is disabled. By default, it is the Windows default backgrond, which is usually grey. If you don't like the foreground color, you can always set that when enabling/disabling it.
procedure enable_textbox(integer id, integer state) if state = False then setTextColor(id, BrightWhite) -- White text when disabled. else setTextCoor(id, Black) -- Black text when enabled. end if setEnable(id, state) end procedure
Then instead of using setEnable(TxtBox, False) use enable_textbox(TxtBox, False)