Hi Dennis,
It seems that the implementation of TextBox.ReadOnly property will
grey the color when you set it to false.
but It's not always set the color, so you may play a trick on it,just like
void ReadOnlyBox()
{
Color tmp = textBox1.BackColor;
textBox1.ReadOnly = true;
//in fact , you only need reset the BackColor when the ReadOnly = true
firstly called.
textBox1.BackColor = tmp;
}
void ReadWriteTextBox()
{
textBox1.ReadOnly = false;
}
this code works on my system, Please tell me if you meet some problems in
using it.
Thanks!
Kind regards,
Ying-Shen Yu [MS]
Microsoft Support Engineer
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
| Content-Class: urn:content-classes:message
| From: "dennist" <
[email protected]>
| Sender: "dennist" <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
| Subject: Re: read-only vs locked textbox
| Date: Mon, 8 Sep 2003 01:32:56 -0700
| Lines: 57
| Message-ID: <
[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcN1483m49hU1lm2SvmwwRa0rXgJuA==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:51847
| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Bob,
|
| thanks for your reply, but....
|
| I'm not going to design my own control for a locked
| property. That's ridiculous, as far as I'm concerned.
| Microsoft should be providing it. Period.
|
| Second, a label control won't do. I need it as a textbox
| at first, at which time it can be edited. Only later
| when everything is in order with other controls do I want
| it locked. Changing it into a label control at that time
| is another preposterous exercise that only a programming
| designer could love. Bring back RAD to VB!!!
|
| Dennis
| >-----Original Message-----
| >You could easily create a control that looked like a
| text box but with a
| >read-only Text property.
| >You'd have to set the text in the constructor or
| something though because
| >you couldn't do it at design time.
| >
| >Why not just use a label?
| >
| >--
| >Bob Powell [MVP]
| >C#, System.Drawing
| >
| >ANNOUNCING: Well Formed.
| >The monthy electronic magazine for
| >Windows Forms and GDI+ engineers
| >
http://www.bobpowell.net/wellformed.htm
| >
| >Check out the GDI+ FAQ
| >
http://www.bobpowell.net/gdiplus_faq.htm
| >
| >
| >| >> the read only property is no substitute for the locked
| >> property of a textbox in vb6. The read only property
| >> allows the text to be changed or wiped out
| >> programmatically. You simply can't change it by
| clicking
| >> in the textbox and start typing.
| >>
| >> Is there any way the this grand new world of vb.net of
| >> doing something so simple and important as locking the
| >> text in a textbox?
| >>
| >> dennist
| >
| >
| >.
| >
|