Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

Skip LinkLabel in TAB order

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Guido Kraus - 01 Apr 2005 10:57 GMT
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
Herfried K. Wagner [MVP] - 01 Apr 2005 12:35 GMT
"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
[quoted text clipped - 5 lines]
> 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.

Signature

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

Guido Kraus - 01 Apr 2005 13:21 GMT
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

> "Guido Kraus" <guido.kraus@newsgroup.nospam> schrieb:
> >I have designed a custom control derived from UserControl which contains a
[quoted text clipped - 9 lines]
> I am not able to reproduce this behavior with .NET 1.1/Windows XP
> Professional SP2.
Kevin Yu [MSFT] - 02 Apr 2005 03:29 GMT
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
Signature

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.