non-editable TextBox?

  • Thread starter Thread starter ORC
  • Start date Start date
O

ORC

Hi,

I'm trying to make a textbox non-editable like a label. So far I have tried
to catch the GotFocus event and throw the focus to another control (this
doesn't do it because one can tab and hold and select paste and this way
insert another text in it) and I have tried to catch the KeyPress event
(this doesn't work either because the Delete key isn't catched this way and
therefore making it possible to delete the content of the "Indicator".

I would be really happy if someone could help me solve this task!

Thanks,
Ole
 
Hi Daniel,

No, the enabled property wont do it because it makes the textbox's backcolor
darkgray and I need it to be white.

Thanks,
Ole
 
Ole said:
No, the enabled property wont do it because it makes the textbox's
backcolor darkgray and I need it to be white.

How about using the Enabled property on a custom control derived from
TextBox, and do the drawing yourself? You could even use the custom
control to hide the Enabled property if that suits your purpose.

See "Developing Compelling User Controls that Target Forms in the .NET
Framework" [1] by David Platt, MSDN Magazine, April 2002.

Cheers,
Stuart Celarier, Fern Creek

[1] http://msdn.microsoft.com/msdnmag/issues/02/04/winforms/
 
Thanks, I'll have a look at it. I have tried to use a label and cathing the
Paint event of it. In the paint event I draw a recatangle but but... even
thought the documentation says so - the paint event seems not to be
supported in CF :-(

Thanks,
Ole

Stuart Celarier said:
Ole said:
No, the enabled property wont do it because it makes the textbox's
backcolor darkgray and I need it to be white.

How about using the Enabled property on a custom control derived from
TextBox, and do the drawing yourself? You could even use the custom
control to hide the Enabled property if that suits your purpose.

See "Developing Compelling User Controls that Target Forms in the .NET
Framework" [1] by David Platt, MSDN Magazine, April 2002.

Cheers,
Stuart Celarier, Fern Creek

[1] http://msdn.microsoft.com/msdnmag/issues/02/04/winforms/
 
You you don't really need a non-editable TextBox, you need a Label with a
border? In that case look at the OpenNETCF LabelEx or just about any intro
on custom controls for the CF, as the Label is typically used because of its
simplicity.

--
<ctacke/>
www.OpenNETCF.org
Your CF searches start and end here


ORC said:
Thanks, I'll have a look at it. I have tried to use a label and cathing
the
Paint event of it. In the paint event I draw a recatangle but but... even
thought the documentation says so - the paint event seems not to be
supported in CF :-(

Thanks,
Ole

Stuart Celarier said:
Ole said:
No, the enabled property wont do it because it makes the textbox's
backcolor darkgray and I need it to be white.

How about using the Enabled property on a custom control derived from
TextBox, and do the drawing yourself? You could even use the custom
control to hide the Enabled property if that suits your purpose.

See "Developing Compelling User Controls that Target Forms in the .NET
Framework" [1] by David Platt, MSDN Magazine, April 2002.

Cheers,
Stuart Celarier, Fern Creek

[1] http://msdn.microsoft.com/msdnmag/issues/02/04/winforms/
 
You're right - a label with a border is exactly what I need - I can't find
the LabelEx you mentioned - please provide more information on where to find
it - Thanks you very much!

Ole

Chris Tacke said:
You you don't really need a non-editable TextBox, you need a Label with a
border? In that case look at the OpenNETCF LabelEx or just about any intro
on custom controls for the CF, as the Label is typically used because of its
simplicity.

--
<ctacke/>
www.OpenNETCF.org
Your CF searches start and end here


ORC said:
Thanks, I'll have a look at it. I have tried to use a label and cathing
the
Paint event of it. In the paint event I draw a recatangle but but... even
thought the documentation says so - the paint event seems not to be
supported in CF :-(

Thanks,
Ole

Stuart Celarier said:
Ole wrote:
No, the enabled property wont do it because it makes the textbox's
backcolor darkgray and I need it to be white.

How about using the Enabled property on a custom control derived from
TextBox, and do the drawing yourself? You could even use the custom
control to hide the Enabled property if that suits your purpose.

See "Developing Compelling User Controls that Target Forms in the .NET
Framework" [1] by David Platt, MSDN Magazine, April 2002.

Cheers,
Stuart Celarier, Fern Creek

[1] http://msdn.microsoft.com/msdnmag/issues/02/04/winforms/
 
OK - made my own user control so further help isn't needed - thank you all.

Ole


ORC said:
You're right - a label with a border is exactly what I need - I can't find
the LabelEx you mentioned - please provide more information on where to find
it - Thanks you very much!

Ole

Chris Tacke said:
You you don't really need a non-editable TextBox, you need a Label with a
border? In that case look at the OpenNETCF LabelEx or just about any intro
on custom controls for the CF, as the Label is typically used because of its
simplicity.

--
<ctacke/>
www.OpenNETCF.org
Your CF searches start and end here


ORC said:
Thanks, I'll have a look at it. I have tried to use a label and cathing
the
Paint event of it. In the paint event I draw a recatangle but but... even
thought the documentation says so - the paint event seems not to be
supported in CF :-(

Thanks,
Ole

Ole wrote:
No, the enabled property wont do it because it makes the textbox's
backcolor darkgray and I need it to be white.

How about using the Enabled property on a custom control derived from
TextBox, and do the drawing yourself? You could even use the custom
control to hide the Enabled property if that suits your purpose.

See "Developing Compelling User Controls that Target Forms in the ..NET
Framework" [1] by David Platt, MSDN Magazine, April 2002.

Cheers,
Stuart Celarier, Fern Creek

[1] http://msdn.microsoft.com/msdnmag/issues/02/04/winforms/
 
I believe the TextBox.ReadOnly property should solve your problem.

Hope this helps.
Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "ORC" <[email protected]>
| Subject: non-editable TextBox?
| Date: Mon, 6 Dec 2004 15:38:47 +0100
| Lines: 15
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host:
cpe.atm2-0-1091129.0x50a0ad5a.arcnxx14.customer.tele.dk 80.160.173.90
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15
..phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:66377
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi,
|
| I'm trying to make a textbox non-editable like a label. So far I have
tried
| to catch the GotFocus event and throw the focus to another control (this
| doesn't do it because one can tab and hold and select paste and this way
| insert another text in it) and I have tried to catch the KeyPress event
| (this doesn't work either because the Delete key isn't catched this way
and
| therefore making it possible to delete the content of the "Indicator".
|
| I would be really happy if someone could help me solve this task!
|
| Thanks,
| Ole
|
|
|
 
Back
Top