﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Ultrawingrid - handling keypress and setting focus to row on enter</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Fri, 11 Sep 2026 10:29:18 GMT</lastBuildDate><ttl>20</ttl><item><title>Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27195.aspx</link><description>&lt;br&gt;
Two Ultrawingrid issues :&lt;br&gt;
&lt;br&gt;
What is the best way to cause the focus to go to the first column of the first row when the grid is entered via tabbing from the previous control.  i.e. so you can immediately start typing or tabbing through the gird.&lt;br&gt;
&lt;br&gt;
How does one handle the keypress so that a ctrl-Tab will exit the grid and move to the next control in the TOController tab order.?&lt;br&gt;
&lt;br&gt;
Thanks &lt;br&gt;
&lt;br&gt;
( if you know the answer and could email it to me I'd appreciate it as i may need it before the forum goes down for maintenance)&lt;br&gt;
&lt;br&gt;</description><pubDate>Thu, 27 May 2010 07:11:24 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27239.aspx</link><description>Glad it helped, Charles! ;)</description><pubDate>Thu, 27 May 2010 07:11:24 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27238.aspx</link><description>Ivan, thank you so much for the groupbox trick to get the TabOrderController to work with Ultrawingrid.  Works beutifully and is very easy to implement.  The ctrl-tab and shift-ctrl-tab still work as designed.  &lt;br&gt;
&lt;br&gt;
For benefit of lurkers ( and me when I forget what I did ) :&lt;br&gt;
&lt;br&gt;
When using a TabControl and multiple pages, you can tab from last control on page1 to first control on page2 by using the Leave event of the page1 control to set the SelectedTab() of the TabControl to page2 and then, in the Enter of page2 set the focus to the next control in the tab sequence.</description><pubDate>Thu, 27 May 2010 06:37:50 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27237.aspx</link><description>Clever idea.  I'll have a look at it tonight.&lt;br&gt;
&lt;br&gt;
Obrigado again ! :)</description><pubDate>Wed, 26 May 2010 17:59:30 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27235.aspx</link><description>Here you are, Charles.&lt;/P&gt;&lt;P&gt;Basicaly, I dropped a GroupBox on the form and moved the grid inside it. Then I rearranged the form Tab order, and set the GroupBox "TabOrder on TabOrderController1" to 2, or whatever gets in the middle of the other 2 controls before and afterhand. Next, I added code to the GroupBox_Enter event to move the focus to the grid:&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Handles GroupBox1.Enter&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- move focus to grid&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.grdCustomers.Focus()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/P&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;And, for the Grid "TabOrder on TabOrderController1", I set -1, so it will tab inside it freely.&lt;/P&gt;&lt;P&gt;Hope it helps. ;)</description><pubDate>Wed, 26 May 2010 15:35:18 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27234.aspx</link><description>Hi Charles.&lt;/P&gt;&lt;P&gt;I have been fighting the UltraGrid for days now! :w00t:&lt;/P&gt;&lt;P&gt;Getting it to do exactly what I want&amp;nbsp;has been&amp;nbsp;a challenge, but so far I am managing to do it. "Someone" has always told me how working with grids&amp;nbsp;was a pain in the neck...&lt;/P&gt;&lt;P&gt;I will have a look at your sample and see if I can come back with some idea. ;)</description><pubDate>Wed, 26 May 2010 14:45:31 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27233.aspx</link><description>Hi Ivan&lt;br&gt;
&lt;br&gt;
I've been working a lot using your ultraWingrid subclassing example.&lt;br&gt;
&lt;br&gt;
First, in order to exit the grid using Ctrl - Tab :&lt;br&gt;
&lt;br&gt;
[codesnippet]        If e.KeyCode = Windows.Forms.Keys.Tab AndAlso e.Control Then&lt;br&gt;
            SetFocusToNextControl(True)&lt;br&gt;
        End If&lt;br&gt;
&lt;br&gt;
        If e.KeyCode = Windows.Forms.Keys.Tab AndAlso e.Control AndAlso e.Shift Then&lt;br&gt;
&lt;br&gt;
            SetFocusToNextControl(False)&lt;br&gt;
        End If&lt;br&gt;
&lt;br&gt;
        If e.KeyCode = windows.Forms.Keys.Delete andalso e.Control then&lt;br&gt;
            Me.currentActiveRow.Delete()&lt;br&gt;
        End If&lt;br&gt;
        MyBase.OnKeyDown(e)[/codesnippet]&lt;br&gt;
&lt;br&gt;
But the weird thing I have discovered is that if you use a SF TabOrderController on the form the tab in the grid will move to the next control (just as ctrl-tab does in the example above) and not tab you through the grid and into add record at the end.&lt;br&gt;
&lt;br&gt;
I've made minor mods to your sample to demonstrate both of these things.  As delivered, you'll see tabbing from country into the grid and then tabbing moves through the grid until you exit with either Ctrl-Tab or Ctrl-Shift-Tab.&lt;br&gt;
&lt;br&gt;
But now drop a SF TabOrderController on the form, set the properties for the three controls and notice tabbing when in the grid moves your to postal code.  &lt;br&gt;
&lt;br&gt;
Obviously, what we need is a way to tell the TabOrderController to ignore the Tab if the container is an ultrawingrid.&lt;br&gt;
&lt;br&gt;
Any ideas?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;</description><pubDate>Wed, 26 May 2010 13:08:06 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27205.aspx</link><description>By the way, I have moved the OnEnter code to the OnGotFocus:&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ActivateCell)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyBase.OnGotFocus(e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/P&gt;&lt;P&gt;[/codesnippet]</description><pubDate>Fri, 21 May 2010 09:07:39 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27204.aspx</link><description>Hi Charles.&lt;/P&gt;&lt;P&gt;SetFocustonextControl(true) is an UltraGrid method, so it will work fine inside an inherited UltraGrid. But then, you want to use Ctrl+Tab to exit the UltraGrid, which I agree is the easier thing for the user to understand, but I wasn't able to catch the keydown Ctrl+Tab&amp;nbsp;from inside the UltraGrid.&lt;/P&gt;&lt;P&gt;In order to do that, I used my BaseForm and added the following code:&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ByVal keyData As System.Windows.Forms.Keys) As Boolean&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- check for unique keystrokes&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select Case keyData&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Case Keys.Control Or Keys.Tab&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- created to be able to tab out of a Grid control&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.SelectNextControl(Me.ActiveControl, True, True, True, True)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return MyBase.ProcessCmdKey(msg, keyData)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Function&lt;/P&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;This worked fine for me, since all forms will tab to next control&amp;nbsp;once the user types&amp;nbsp;Ctrl+Tab.&lt;/P&gt;&lt;P&gt;Regarding the Subs, they are overriding the grid's OnKeyDown (which we don't need anymore since we are testing the ProcessCmdKey in our base form) and OnEnter subs. That is why we call the MyBase.OnEnter(e) (remember DODEFAULT()? :))&lt;/P&gt;&lt;P&gt;Thanks for the question, I wanted to write these features&amp;nbsp;for myself as well. :D</description><pubDate>Fri, 21 May 2010 08:37:26 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27202.aspx</link><description>My apologies.  I should have studied your excellent Ultragrid sample app before posting.  I am going to study that, fix my subclass and try it again.  I think I am starting to understand.&lt;br&gt;
&lt;br&gt;
Thanks for the sample !&lt;br&gt;
&lt;br&gt;</description><pubDate>Thu, 20 May 2010 17:59:19 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27201.aspx</link><description>Sorry.  I'm being a little stupid.  i tried putting this in my subclass&lt;br&gt;
&lt;br&gt;
[codesnippet]Imports Infragistics&lt;br&gt;
Imports Infragistics.Shared&lt;br&gt;
Imports System.Windows.Forms&lt;br&gt;
&lt;br&gt;
Public Class uWingrid&lt;br&gt;
    Inherits Infragistics.Win.UltraWinGrid.UltraGrid&lt;br&gt;
&lt;br&gt;
    Public Sub New()&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
        Me.DisplayLayout.CaptionVisible = Win.DefaultableBoolean.False&lt;br&gt;
        Me.DisplayLayout.GroupByBox.Hidden = True&lt;br&gt;
        Me.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.FixedAddRowOnBottom&lt;br&gt;
        Me.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.[True]&lt;br&gt;
        Me.DisplayLayout.Override.AllowRowSummaries = Infragistics.Win.UltraWinGrid.AllowRowSummaries.[False]&lt;br&gt;
        Me.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.[True]&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
    End Sub&lt;br&gt;
    Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)&lt;br&gt;
        If e.KeyCode = Keys.E AndAlso e.Control Then&lt;br&gt;
            SetFocusToNextControl(True)&lt;br&gt;
        End If&lt;br&gt;
        MyBase.OnKeyDown(e)&lt;br&gt;
    End Sub&lt;br&gt;
&lt;br&gt;
    Protected Overrides Sub OnEnter(ByVal e As System.EventArgs)&lt;br&gt;
        Me.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ActivateCell)&lt;br&gt;
        Me.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode)&lt;br&gt;
&lt;br&gt;
        MyBase.OnEnter(e)&lt;br&gt;
    End Sub&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
End Class&lt;br&gt;
[/codesnippet]&lt;br&gt;
&lt;br&gt;
The two sub don't seem to be event handlers and they don't appear to be being called.&lt;br&gt;
&lt;br&gt;
If I have a form with 13 ultragrids, where would I put the subs ?  Or f I wanted this behavior for a single grid?  It looks like the code should be in a subclass, but I think I'm missing something about subclassing the grid ....?&lt;br&gt;
&lt;br&gt;
I guess my brain isn't working today.&lt;br&gt;</description><pubDate>Thu, 20 May 2010 17:50:41 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27200.aspx</link><description>Super !  Thanks Ivan.  I'll try these tonight.&lt;br&gt;
 &lt;br&gt;
SetFocustonextControl(true) is really new to me but i thought there had to be something like that available.&lt;br&gt;</description><pubDate>Thu, 20 May 2010 16:01:05 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Ultrawingrid - handling keypress and setting focus to row on enter</title><link>http://forum.strataframe.net/FindPost27199.aspx</link><description>Hiya.&lt;/P&gt;&lt;P&gt;This is to Exit and Set Focus to next control. I haven't been able to catch Ctrl+Tab. If you manage it, please let&amp;nbsp;me know:&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If e.KeyCode = Keys.E AndAlso e.Control Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SetFocusToNextControl(True)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyBase.OnKeyDown(e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/P&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;And this is to enter in Edit mode:&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Protected Overrides Sub OnEnter(ByVal e As System.EventArgs)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ActivateCell)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyBase.OnEnter(e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/P&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;Hope it helps. ;)</description><pubDate>Thu, 20 May 2010 15:51:05 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item></channel></rss>