Setting focus to a particular control based on TabOrder on TabOrderController


Author
Message
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
I have a subclass of groupbox I want to use for my grids. For reasons shown in another thread, if my grid, in a groupbox, is on a tabpage, as I leave the groupbox it is getting a little stupid about setting focus to the next control in the taborder (using a tabordercontroller) Right now I am manually setting focus to a control, by name. I have made this generic



Imports System.Windows.Forms



Public Class GridGroupbox

Inherits MicroFour.StrataFrame.UI.Windows.Forms.GroupBox



Private _NextControl As String

Public Property NextControl() As String

Get

Return _NextControl

End Get

Set(ByVal value As String)

_NextControl = value

End Set

End Property





Private Sub MyGroupbox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Enter

Me.Controls(0).Focus()

End Sub



Private Sub GridGroupbox_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Leave

If Not String.IsNullOrEmpty(Me.NextControl()) Then

Dim myform As Form = Me.FindForm()

Dim nc() As Control

nc = myform.Controls.Find(Me.NextControl, True)

nc(0).Focus()

End If

End Sub

End Class




First, is there a better way to get an object reference to a control when I have a string that represents the name of that control ?



Second, is a there a generic way I can say "If the this control has a taborder property for a TOcontroller, set focus to the control which has a taborder property = me.taborder + 1



I assume I can start with the form, find the TabOrderController and then find the control reference in its collection to the next control ? Or is there something better ?



This is fun BigGrin
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search