Hi,

I want to use a Textbox in my app that the user can't edit and select
anything on it. To do it I have to disable (Enabled = false) but when I do
that the text color change to grey.

How can I change a disabled textbox's forecolor? or how can I prevent the
selection of text?

Thank you very much.

Re: How to change a disabled textbox's forecolor? by Michael

Michael
Tue May 06 07:03:46 CDT 2008

Did you try setting the ForeColor property?

Is the "how can I prevent selection" question separate? Or that's what you
want the final result to be? I.e. you don't really care what color it is as
long as you prevent selection of text? In any case, not sure why you'd want
to prevent selection (why would you?), but probably the only way to do it is
handle mouse events. For example, create a MouseClick handler and probably
have it do nothing -just return. Can get sticky, so be careful! You could
end up with unintended side effects.

--
Michael Salamone, eMVP
Entrek Software, Inc.
www.entrek.com


"Liberado27" <Liberado27@discussions.microsoft.com> wrote in message
news:E97A2B94-E7AF-496E-8E0F-A59FEDF94BE1@microsoft.com...
> Hi,
>
> I want to use a Textbox in my app that the user can't edit and select
> anything on it. To do it I have to disable (Enabled = false) but when I do
> that the text color change to grey.
>
> How can I change a disabled textbox's forecolor? or how can I prevent the
> selection of text?
>
> Thank you very much.


Re: How to change a disabled textbox's forecolor? by Liberado27

Liberado27
Tue May 06 08:38:15 CDT 2008

My goal is prevent selection.

I can achived that if I disable the TextBox, but if I do that the text color
gone grey. Because of that I want to change the forecolor when the textbox is
disabled.

My app is for Windows Mobile 5.0 and Compact Framework 2.0.

Thanks for your answer.


"Michael Salamone" wrote:

> Did you try setting the ForeColor property?
>
> Is the "how can I prevent selection" question separate? Or that's what you
> want the final result to be? I.e. you don't really care what color it is as
> long as you prevent selection of text? In any case, not sure why you'd want
> to prevent selection (why would you?), but probably the only way to do it is
> handle mouse events. For example, create a MouseClick handler and probably
> have it do nothing -just return. Can get sticky, so be careful! You could
> end up with unintended side effects.
>
> --
> Michael Salamone, eMVP
> Entrek Software, Inc.
> www.entrek.com
>
>
> "Liberado27" <Liberado27@discussions.microsoft.com> wrote in message
> news:E97A2B94-E7AF-496E-8E0F-A59FEDF94BE1@microsoft.com...
> > Hi,
> >
> > I want to use a Textbox in my app that the user can't edit and select
> > anything on it. To do it I have to disable (Enabled = false) but when I do
> > that the text color change to grey.
> >
> > How can I change a disabled textbox's forecolor? or how can I prevent the
> > selection of text?
> >
> > Thank you very much.
>

Re: How to change a disabled textbox's forecolor? by Scott

Scott
Tue May 06 09:52:14 CDT 2008

=?Utf-8?B?TGliZXJhZG8yNw==?= <Liberado27@discussions.microsoft.com> wrote:
>
>My goal is prevent selection.
>
>I can achived that if I disable the TextBox, but if I do that the text color
>gone grey. Because of that I want to change the forecolor when the textbox is
>disabled.

If you want a text box that can't be selected and can't be edited, why
not use a static (label)?

--
--------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
Luck is probability taken personally.
-- Chip Denman

Re: How to change a disabled textbox's forecolor? by Liberado27

Liberado27
Tue May 06 10:10:01 CDT 2008

Because I need a multiline control with scrollbars.

"Scott Seligman" wrote:

> =?Utf-8?B?TGliZXJhZG8yNw==?= <Liberado27@discussions.microsoft.com> wrote:
> >
> >My goal is prevent selection.
> >
> >I can achived that if I disable the TextBox, but if I do that the text color
> >gone grey. Because of that I want to change the forecolor when the textbox is
> >disabled.
>
> If you want a text box that can't be selected and can't be edited, why
> not use a static (label)?
>
> --
> --------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
> Luck is probability taken personally.
> -- Chip Denman
>

Re: How to change a disabled textbox's forecolor? by Liberado27

Liberado27
Wed May 07 08:27:00 CDT 2008

I solved this problem putting a label inside a panel, and changing the
autoscroll panel's property to true.

Thanks!


"Liberado27" wrote:

> Because I need a multiline control with scrollbars.
>
> "Scott Seligman" wrote:
>
> > =?Utf-8?B?TGliZXJhZG8yNw==?= <Liberado27@discussions.microsoft.com> wrote:
> > >
> > >My goal is prevent selection.
> > >
> > >I can achived that if I disable the TextBox, but if I do that the text color
> > >gone grey. Because of that I want to change the forecolor when the textbox is
> > >disabled.
> >
> > If you want a text box that can't be selected and can't be edited, why
> > not use a static (label)?
> >
> > --
> > --------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
> > Luck is probability taken personally.
> > -- Chip Denman
> >

Re: How to change a disabled textbox's forecolor? by Arun

Arun
Fri May 09 13:18:37 CDT 2008

You can also achieve the same with the textbox, see the below post
wherein I gave a sample TextBoxEx which does the same as you expect.
http://groups.google.com/group/microsoft.public.dotnet.framework.compactfram=
ework/browse_thread/thread/0b819b8d9e48bbf6#

Cheers,
Arun.

On May 7, 6:27=A0am, Liberado27 <Liberad...@discussions.microsoft.com>
wrote:
> I solved this problem putting a label inside a panel, and changing the
> autoscroll panel's property to true.
>
> Thanks!
>
>
>
> "Liberado27" wrote:
> > Because I need a multiline control with scrollbars.
>
> > "Scott Seligman" wrote:
>
> > > =3D?Utf-8?B?TGliZXJhZG8yNw=3D=3D?=3D <Liberad...@discussions.microsoft=
.com> wrote:
>
> > > >My goal is prevent selection.
>
> > > >I can achived that if I disable the TextBox, but if I do that the tex=
t color
> > > >gone grey. Because of that I want to change the forecolor when the te=
xtbox is
> > > >disabled.
>
> > > If you want a text box that can't be selected and can't be edited, why=

> > > not use a static (label)?
>
> > > --
> > > --------- Scott Seligman <scott at <firstname> and michelle dot net> -=
--------
> > > =A0 =A0Luck is probability taken personally.
> > > =A0 =A0-- Chip Denman- Hide quoted text -
>
> - Show quoted text -