Question Override textBox "disabled" color scheme?

CathInfo

Member
Joined
Jun 5, 2008
Messages
9
Programming Experience
5-10
I want to display a line of text with word wrapping, and I don't want the user to be able to edit it. (It's a message -- therefore it should be read-only)

I tried a Label inside a Panel, but that doesn't offer word wrapping.
I tried a textBox, but here is the problem with that solution:

I can't display the message in whatever color I want (namely, black). When I make it "off-limits" for user editing -- i.e., marking it disabled -- it automatically makes all the text a light grey color. I tried manually setting the ForeColor to black, but that didn't work.

It seems like I'd have to override part of the textBox class to achieve what I'm after -- would it be easier to just go the Label route and write a WordWrap routine (which I can do) or is there a simpler solution to achieve black text on a disabled textBox?

Thanks,

Matthew
 
Label control does have text wrap, you have to turn off AutoSize or else set MaximumSize (Width).
 
I tried turning AutoSize off AND setting a max width -- never does "WordWrap" show up: neither in the Autocomplete list of commands nor in the properties window.

I'm using VB.net 2008 Express Edition.

Is there a specific kind of Label I need to use? I'm using the regular .Net 2.0.0.0 Label control. (And yes I'm using .Net 3.5)

If I try to set WordWrap by false, here is the error I get:

VB.NET:
Error	14	'WordWrap' is not a member of 'System.Windows.Forms.Label'.	C:\Projects\Control Panel\matt_Message.vb	11	9	cpanel


Matthew
 
Last edited:
hmm... interesting. Labels wrap text by default when you limit the width, there's no setting for it except the two options I described in previous post in order for the Label to not autosize itself to the lines width.
 
so you are just using a regular text box right? im not sure if this works in the version of vb.net you have, but in the 2008 express edition, if you have a textbox, you can click a little arrow in the right top corner and there is a checkbox for multilined, click that. Then in properties for the text box, make it readonly. Then you should be able to go to the property box for the text box, and change forecolor and backcolor, the font and background in their respective orders. And to make the text box flat instead of in a little bit, go to borderstyle, and select none.

IF YOU DON'T FEEL LIKE READING ALL THAT, HERES A SUMMARY:
1. click arrow in right corner, select multiline
2. size textbox so all of message shows
3. go to text box properties on right side and make read only = true
4. go to text box properties on right side and make borderstyle = none
5. go to fore color to change font color if you want
6. go to back color to change background color if you want

i hope this helps

im almost positive it should work, it worked on the 2008 edition
and 2005
 
Back
Top