Arun
Fri May 09 12:59:51 CDT 2008
Hi Serge,
Set the textbox tabstop property to false.
this.textBox1.TabStop =3D false;
But still it will allow user to tap on the textbox to get the focus,
you can add gotfocus event and put the focus to form, soemthing like
this.
This is because, you cannot capture mouse events and click event on CF
textbox control.
private void textBox1_GotFocus(object sender, EventArgs e)
{
textBox1.TopLevelControl.Focus();
}
If you have multiple textboxes to do the same stuff, create a extended
textbox control and override the gotfocus.
public class TextBoxEx : TextBox
{
public TextBoxEx()
{
ReadOnly =3D true;
}
protected override void OnGotFocus(EventArgs e)
{
this.TopLevelControl.Focus();
base.OnGotFocus(e);
}
}
Hope this helps,
Cheers,
Arun
On May 9, 7:10=A0am, "Armando Rocha" <armandoro...@ifthensoftware.com>
wrote:
> Hi,
>
> focus on form dont work, but if you define textbox.enable =3D false; then
> focus is not set.
>
> --
> Armando Rocha
> Mobile Developer
>
>
http://www.ifthensoftware.com
> "Armando Rocha" <armandoro...@ifthensoftware.com> escreveu na mensagemnews=
:89F374EA-E61F-4978-B930-F3BBB2EF0F1B@microsoft.com...
>
>
>
> > hi,
>
> > try put the focus on form (this.focus())
>
> > --
> > Armando Rocha
> > Mobile Developer
>
> >
http://www.ifthensoftware.com
> > "Serge Wautier" <se...@wautier.nospam.net> escreveu na mensagem
> >news:eMvrcqdsIHA.4716@TK2MSFTNGP06.phx.gbl...
> >> Env.: WM6 / VS2008 / CF 3.5
>
> >> Hi All,
>
> >> I have this winform used to view info (not edit it). It contains a set =
of
> >> labels and textboxes set in readonly mode.
>
> >> The problem is that the focus is set automatically to first text box an=
d
> >> the caret is displayed. This is confusing to users because you think yo=
u
> >> can type something in there. How can I get rid of this caret?
>
> >> My dirty workaround is as such: ((Control)MyLabel).Focus();
>
> >> -> Sets the focus to a label. It's dirty because Label hides Focus()
> >> (hence the typecast). Which means I'm not supposed to use it. (BTW the
> >> compiler emits a warning to remind me so).
>
> >> Does anyone know of a more elegant/'legal' solution?
>
> >> Note: Turning the textboxes into labels is not a good option here becau=
se
> >> the form is sometimes used in 'view' mode and sometimes in 'edit' mode.=
> >> And I want to keep a single layout for both modes.
>
> >> TIA,
>
> >> Serge.- Hide quoted text -
>
> - Show quoted text -