Re: How to scroll to text box when keyboard is displayed
- From: "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com>
- Date: Thu, 27 Aug 2009 10:45:32 -0700
Well, basically, you want to adjust the autoscroll position so that the
control is in the right place. There are an infinite number of special
cases (where is the input panel? on a wide screen device, the input panel
might be right in the middle of the screen; how do I make a given control
visible in that situation, etc.), but something basically like this will
probably show up:
int pos = focusedControl.Location.Y;
currentTabPage.AutoScrollPosition =
new Point( 0, pos - currentTabPage.AutoScrollPosition.Y );
Paul T.
"The Mad Ape" <chiefape@xxxxxxxxx> wrote in message
news:h76cmf$1a2$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Paul G. Tobey [eMVP] wrote:
Wait, you want to tab to the next text box or move the text in a given
text box? Windows on Windows CE work basically just like they do on the
desktop (Tab to the next one, use the Down arrow to scroll).
When the input panel is enabled and there is a textbox that has focus
hidden behind the input panel, I have to manually scroll to that textbox
to enter data.
In my quest to make user input as efficient as possible, I want code that
detects when a textbox is obscured by the input panel. When detected I
want the textbox to show its ugly head automatically, without manually
scrolling to it.
Just saves a step but when a user does it a hundred times per day or more
it is time that adds up.
Thanks
TMA
Paul T.
"The Mad Ape" <chiefape@xxxxxxxxx> wrote in message
news:a1dc0c28-6280-4852-aad8-8f1649d69aae@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Aug 27, 12:28 pm, The Mad Ape <chief...@xxxxxxxxx> wrote:
I have code in the GotFocus event that will display the virtual
keyboard when the focused object is a textbox. Not a problem, works
like a charm.
However if the next box is obscured by the keyboard I can not get the
autoscroll to work.
Here is the code to scroll to the textbox:
Private Sub txt1_LostFocus (ByVal sender As Objectm ByVal e As
System.EventArgs) Handles txt1.LostFocus
'This section just closes the Keyboard upon losing focus to this text
box. It works fine
If not InputPanel1 is Nothing Then
If InputPanel1.Enabled = True Then
InputPanel1.Enabled = False
End If
End If
'This does not work
If txt2.Visible = True Then
txt2.Focus()
txt2.ScrollToCaret()
End If
Also For your info I have this code in the GotFocus for txt2
If not InputPanel1 is Nothing Then
If InputPanel1.Enabled = False Then
InputPanel1.Enabled = True
End If
End If
Any ideas? There are other objects above these textboxes so by the
time the use gets to them, they have to enter data, scroll down to the
next one and enter data. It does set the focus on txt2 but it does not
scroll to it.
How can I fix this?
Thanks
TMA
I should also point out that the textboxes exist in a tab in Form 2.
I have used the EnabledChanged feature of the InputPanel to adjust
form size and scrolling.
Private Sub InputPanel1_EnabledChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
InputPanel1.EnabledChanged
If InputPanel1.Enabled = False Then
For Each tbPge In tabCruise.TabPages
tbPge.AutoScroll = False
Next
tabCruise.Height = 267
tabCruise.Width = 240
Else
' The SIP is enabled, so the height of the tab control
' is set to the height of the visible desktop area.
For Each tbPge In tabCruise.TabPages
tbPge.AutoScroll = True
tbPge.AutoScrollMargin = New Size(5, 5)
Next
tabCruise.Height = InputPanel1.VisibleDesktop.Height
tabCruise.Width = InputPanel1.VisibleDesktop.Width
End If
End Sub
.
- Follow-Ups:
- Re: How to scroll to text box when keyboard is displayed
- From: The Mad Ape
- Re: How to scroll to text box when keyboard is displayed
- References:
- How to scroll to text box when keyboard is displayed
- From: The Mad Ape
- Re: How to scroll to text box when keyboard is displayed
- From: The Mad Ape
- Re: How to scroll to text box when keyboard is displayed
- From: Paul G. Tobey [eMVP]
- Re: How to scroll to text box when keyboard is displayed
- From: The Mad Ape
- How to scroll to text box when keyboard is displayed
- Prev by Date: Re: System.ArgumentException on close when dialog not on top
- Next by Date: Re: System.ArgumentException on close when dialog not on top
- Previous by thread: Re: How to scroll to text box when keyboard is displayed
- Next by thread: Re: How to scroll to text box when keyboard is displayed
- Index(es):
Relevant Pages
|