|
-
May 15th, 2007, 05:47 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2005] Textbox.enabled question
Hi guys,
this is probably a really easy question, but is there any way to disable a textbox but still allow the scroll bar to scroll, because i am setting up a simple messaging system.
Now i am displaying it in a textbox, but have disabled the textbox so that the user cant alter any of the text in the message they are reading. But if the message is longer than what will fit in the textbox then the user cant read the rest of the message because the scrollbar is also disabled.
So is there any way around this?
Thanks in advance for any help
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
May 15th, 2007, 05:50 AM
#2
Re: [2005] Textbox.enabled question
So, if you set the scroll property to vertical and the textbox to read only, the scroll bars still work.
-
May 15th, 2007, 05:54 AM
#3
Junior Member
Re: [2005] Textbox.enabled question
suppose ur textbox name is text1 then add the following code
vb Code:
Private sub text1_keypress(byval keyascii as integer)
Select case chr(keyascii)
case else
keyascii=0
end select
end sub
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post
-
May 15th, 2007, 05:55 AM
#4
Re: [2005] Textbox.enabled question
A disabled control is one that accepts no user interaction. Scrolling is user interaction so that's not disabled.
As I'm sure I've suggested to you before, if you want to do something with or to a class you should look at what members the class provides before doing ANYTHING else. Had you done that you'd have seen the ReadOnly property, which name I would think would suggest to you its use. If not then the description surely would have:
Controls whether the text in the edit control can be changed or not.
Presumably you were using the IDE when you decided you need this so the Properties window would have been right there in front of you. Don't ignore the obvious resources at your disposal.
-
May 15th, 2007, 05:56 AM
#5
Junior Member
Re: [2005] Textbox.enabled question
u dont have to alter the text box properties
-
May 15th, 2007, 05:58 AM
#6
Re: [2005] Textbox.enabled question
 Originally Posted by tarencer
u dont have to alter the text box properties
Your code is for VB6 so not relevant to VB.NET. Also, why would you bother writing code when you can set a single property at design time that is specifically designed to perform the desired task?
-
May 15th, 2007, 05:58 AM
#7
Re: [2005] Textbox.enabled question
 Originally Posted by jmcilhinney
A disabled control is one that accepts no user interaction. Scrolling is user interaction so that's not disabled.
As I'm sure I've suggested to you before, if you want to do something with or to a class you should look at what members the class provides before doing ANYTHING else. Had you done that you'd have seen the ReadOnly property, which name I would think would suggest to you its use. If not then the description surely would have:Presumably you were using the IDE when you decided you need this so the Properties window would have been right there in front of you. Don't ignore the obvious resources at your disposal.
lol, he makes a good point
-
May 15th, 2007, 05:58 AM
#8
Thread Starter
Fanatic Member
Re: [2005] Textbox.enabled question
I tried the readonly option, but that made the appearance of the form seem worse because the backcolor of the textbox changed to the colour of the panel it was on and also it displayed the caret which i didn't want.
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
May 15th, 2007, 05:59 AM
#9
Re: [2005] Textbox.enabled question
but that made the appearance of the form seem worse because the backcolor of the textbox changed to the colour of the panel
Surely the simple solution would be to change its BackColor property again after making it Read Only....
-
May 15th, 2007, 06:00 AM
#10
Thread Starter
Fanatic Member
Re: [2005] Textbox.enabled question
Nope...it tried that...the backcolor of the textbox is white, then when i make it readonly it changes it to the backcolor of the panel (which is blue).
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
May 15th, 2007, 06:01 AM
#11
Re: [2005] Textbox.enabled question
 Originally Posted by Kimmy4
I tried the readonly option, but that made the appearance of the form seem worse because the backcolor of the textbox changed to the colour of the panel it was on and also it displayed the caret which i didn't want.
It's always a good idea to provide all relevant information when posting. If you don't like the BackColor then change it. As for the caret, the text is still selectable to facilitate copying to the clipboard but I believe that there's a Windows API function that will hide it.
-
May 15th, 2007, 06:01 AM
#12
Fanatic Member
Re: [2005] Textbox.enabled question
then, change the backcolor of ur textbox
TextBox1.BackColor = Color.White
-
May 15th, 2007, 06:02 AM
#13
Re: [2005] Textbox.enabled question
 Originally Posted by Kimmy4
Nope...it tried that...the backcolor of the textbox is white, then when i make it readonly it changes it to the backcolor of the panel (which is blue).
Setting the ReadOnly property to True sets the BackColor property to Control. You then simply set the BackColor rpoperty to Window AFTERWARDS.
-
May 15th, 2007, 06:03 AM
#14
Re: [2005] Textbox.enabled question
 Originally Posted by Kimmy4
I tried the readonly option, but that made the appearance of the form seem worse because the backcolor of the textbox changed to the colour of the panel it was on and also it displayed the caret which i didn't want.
It just sets the backcolor property, you can change it back with no problem it's not property reliant.
As for the newline symbols, i dont seem to get that problem, are you using VbNewLine ?
-
May 15th, 2007, 06:03 AM
#15
Re: [2005] Textbox.enabled question
 Originally Posted by pvbangera
then, change the backcolor of ur textbox
TextBox1.BackColor = Color.White
Use Window, not White. That way it will be consistent regardless of the current theme.
-
May 15th, 2007, 06:05 AM
#16
Re: [2005] Textbox.enabled question
edit: I'm too slow
-
May 15th, 2007, 06:16 AM
#17
Thread Starter
Fanatic Member
Re: [2005] Textbox.enabled question
As for the caret, the text is still selectable to facilitate copying to the clipboard but I believe that there's a Windows API function that will hide it.
I found the code to get rid of the caret a while and tried it but couldn't get it to work as i kept getting an error, i found a post with someone else who was getting the same error and nobody had come up with a solution and i couldn't find one when searching the net for one.
Use Window, not White. That way it will be consistent regardless of the current theme.
In the code i am writing the lines:
txtMessage.ReadOnly = True
txtMessage.BackColor = Color.White
How do i set it to window in code (not using the properties) as it only gives the color. options? And even using that code it still made the textbox backcolor blue!
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
May 15th, 2007, 06:19 AM
#18
Re: [2005] Textbox.enabled question
 Originally Posted by Kimmy4
In the code i am writing the lines:
txtMessage.ReadOnly = True
txtMessage.BackColor = Color.White
How do i set it to window in code (not using the properties) as it only gives the color. options? And even using that code it still made the textbox backcolor blue!
That code worked perfectly for me.
-
May 15th, 2007, 06:30 AM
#19
Thread Starter
Fanatic Member
Re: [2005] Textbox.enabled question
Edit: It seems there is another problem which is causing the text to disappear as my boss has changed the xml file i am getting it from so i've gotta wait until he changes it back before i can test properly whether the color change works.
I'll let you know.
Last edited by Kimmy4; May 15th, 2007 at 06:35 AM.
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
May 15th, 2007, 06:35 AM
#20
Re: [2005] Textbox.enabled question
 Originally Posted by Kimmy4
I added the color change code after i added the text to the textbox and it changed the color of the textbox...but now i have lost my text.
I guess i'm just going to have to leave it as blue! 
Text being lost from a color change im pretty sure is NOT normal behaviour, either you have a problem with your framework, or more likely, there's more code to this issue that you're not telling us about.
-
May 15th, 2007, 06:40 AM
#21
Re: [2005] Textbox.enabled question
Oops! I forgot to post my own code in post #18. Should have been:
vb.net Code:
txtMessage.ReadOnly = True
txtMessage.BackColor = SystemColors.Window
The actual Colors returned by the members of the SystemColors class are determine by the current Windows theme. Window will return White in the default theme but may return some other colour in another theme.
-
May 15th, 2007, 06:43 AM
#22
Thread Starter
Fanatic Member
Re: [2005] Textbox.enabled question
Phill64 -> I editted my post before i got ur reply! There is another problem as explained in post #19.
jmcilhinney -> Thanks for that, i'll try that out as soon as my earlier problem is fixed by my boss.
Last edited by Kimmy4; May 15th, 2007 at 07:01 AM.
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
May 15th, 2007, 09:41 AM
#23
Thread Starter
Fanatic Member
Re: [2005] Textbox.enabled question
Tried it after my boss fixed his problem and it still didn't change the color, but my boss said the blue will do.
Thanks everyone for their input. 
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
May 15th, 2007, 06:17 PM
#24
Re: [RESOLVED] [2005] Textbox.enabled question
The colour change is supposed to be a visual cue to the user that the field is read-only anyway, so having it so not such a bad idea.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|