AboutSyed Rizwan Muhammad Rizvi Expertise I can answers questions regarding web based and desktop based programming in VB.Net. Which can include SOAP, XML, Custom Controls, COM Interoperability etc.
Experience Have been working in this specific area for last 2 years previously I was a VB 6 Developer with experties in other languages as well. Total 10 years of programming experience.
Question QUESTION: In a followup to the person who wanted to use the Enter key to advance to the next control... The issue I'm having is that my Form has a series of Panels (each w/ several controls). The GetNextControl is not returning a value (I presume because no control is selected in the Main Form). Is there a way to determine the current control (or parent control) that has the focus?
The problem I'm trying to solve involves a window mobile application. I'd like the "Enter" button to toggle between Edit/View modes. When in View mode, I'd like the Up/Down/Left/Right arrows to move about the screen, When in Edit mode, I'd like it to move about the control and select a value. Thus when in a Combo boxes, DateTimePickers, you would click the Enter to enter Edit mode, select a value (using default behavior) and click the Enter button to then be able to navigate to the next / prev field. It is very important in a mobile application to be able to have an interface to allow for one handed usage.
ANSWER: there should be an ActiveControl property of the form/container that you are using.
You can then use the TabIndex property of each control to find which control you can should be setting the focus on.
Hope this helps.
Regards,
Riz
---------- FOLLOW-UP ----------
QUESTION: I'll try that but my debugging shows that it is only looking for the active control in the Main form and not panels.
Here is the code that I'm using...
Private Function GetFocusedControl() As Control
For Each c As Control In Me.Controls
If c.Focused Then
Return c
End If
Next
End Function
In the above code, no control was being returned as active. I just changed it to all True's and perhaps that made it work.
I'll keep working at it but would appreciate any feedback you might have.
Thanks.
I may have fixed this earlier by turning on the "nested" option but not sure.
Answer Try this:
Private Function GetFocusedControl(colControls as ControlsCollection) As Control
For Each c As Control In colControls
If c.Focused Then
Return c
End If
If c.controls.count>0 Then
Return GetFocusedControl(c.controls)
End If
Next
End Function
The call would become:
Me.SelectNextControl(GetFocusedControl(Me.Controls), True, True, False, True)