I have designed a custom control derived from UserControl which contains a
LinkLabel and a TextBox. If the user uses the TAB key to move the focus to my
custom control I want the TextBox to get the focus and not the LinkLabel.
Therefore I set the TabStop property of the LinkLabel control to False (in
the constructor of my custom control, after InitializeComponent()). However,
the TabStop property of the LinkLabel is ignored and it still gets the focus.
As a workaround I tried to override OnEnter of my custom control:

Protected Overrides Sub OnEnter(ByVal e As System.EventArgs)
myTextBox.Focus()
End Sub

Unfortunately this doesn't work either. The TextBox gets the focus but
immediately afterwards the focus moves to the LinkLabel. Overriding
OnGotfocus results in the same behaviour.
How could I prevent the LinkLabel to get the focus if the user uses the TAB
key to move the focus to my custom control?

Thanks for any ideas,
Guido

Re: Skip LinkLabel in TAB order by Herfried

Herfried
Fri Apr 01 05:35:49 CST 2005

"Guido Kraus" <guido.kraus@newsgroup.nospam> schrieb:
>I have designed a custom control derived from UserControl which contains a
> LinkLabel and a TextBox. If the user uses the TAB key to move the focus to
> my
> custom control I want the TextBox to get the focus and not the LinkLabel.
> Therefore I set the TabStop property of the LinkLabel control to False (in
> the constructor of my custom control, after InitializeComponent()).
> However,
> the TabStop property of the LinkLabel is ignored and it still gets the
> focus.

I am not able to reproduce this behavior with .NET 1.1/Windows XP
Professional SP2.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Re: Skip LinkLabel in TAB order by guido

guido
Fri Apr 01 06:21:02 CST 2005

You are right. I was fooled by the TabStop property of the LinkLabel which is
automatically set to True if you change the Text property of the LinkLabel.
My custom control exposes a LinkText property which sets the text of the
LinkLabel. Therefore the container of my custom control silently activated
the TabStop property by setting the text of the LinkLabel. So the simple
solution to the problem is:

Public Property LinkText() As String
Get
Return lnkLink.Text
End Get
Set(ByVal Value As String)
lnkLink.Text = Value
lnkLink.TabStop = False
End Set
End Property


"Herfried K. Wagner [MVP]" wrote:

> "Guido Kraus" <guido.kraus@newsgroup.nospam> schrieb:
> >I have designed a custom control derived from UserControl which contains a
> > LinkLabel and a TextBox. If the user uses the TAB key to move the focus to
> > my
> > custom control I want the TextBox to get the focus and not the LinkLabel.
> > Therefore I set the TabStop property of the LinkLabel control to False (in
> > the constructor of my custom control, after InitializeComponent()).
> > However,
> > the TabStop property of the LinkLabel is ignored and it still gets the
> > focus.
>
> I am not able to reproduce this behavior with .NET 1.1/Windows XP
> Professional SP2.
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>
>
>

Re: Skip LinkLabel in TAB order by v-kevy

v-kevy
Fri Apr 01 20:29:11 CST 2005

Hi Guido,

It was nice hear that you have had the problem resolved. Thanks for sharing
your experience with all the people here. If you have any questions, please
feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."