Ultragrid - ctrl-TAB won't work out of UG in groupbox when on TabPage


Author
Message
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
This is both interesting and frustrating ( like so many things in our profession Wink )



In the example the only change i have made to Ivan's clever trick of placing the UG in a groupbox which handles the TabOrderController is to put that groupbox on a TabPage ( and are all the ultragrids in my app )



ctrl-Tab seems reserved to move between tab pages. But ctrl-E is also a problem. Not sure where the focus goes, since in watch window it shows e.keycode is not keys.E but CntrlKey {17} ( this is also true when it is Cntrl-TAB )



Oddly, Ctrl-A, Ctrl-X etc work as expected. And my code in the OnKeydown to have cntrl-Delete delete the row works fine, so I am not sure how the keycode is getting intercepted by the TabControl..



Notice in the sample that if the TabControl is removed, the groupbox/ultragrid work exactly as in the original example.



I have not been able to figure out if this is a SF thing or just a .NET tabcontrol thing or where to intervene.



If it is not fixable I need to convert my app to use panels or something instead but before I go that direction I'd like to know this can't be fixed and that I am not going to have the same problem there.



Thanks in advance ( Ivan BigGrin )
Attachments
UtragridSample2.zip (143 views, 191.00 KB)
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Charles.

I'm out of office right now and won't be able to test your sample fully, but one thing I noticed after a quick look is that on my original sample, I was dealing with keystrokes on the BaseForm, overriding the ProcessCmdKey, while you are dealing with it inside your BaseGrid. Guess that this could make a difference.

Talk to you later. Wink


Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
There is no override of ProcessCmdKey anywhere in your sample but that seems to be the right direction. I tried this code in the MyBaseUltraGrid.vb



Protected Overloads Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean

Const WM_KEYDOWN As Integer = &H100

Const WM_SYSKEYDOWN As Integer = &H104



If (msg.Msg = WM_KEYDOWN) OrElse (msg.Msg = WM_SYSKEYDOWN) Then

Select Case keyData



Case (Keys.Control Or Keys.Tab)

SetFocusToNextControl(True)

Exit Select



Case (Keys.Control Or Keys.E)

SetFocusToNextControl(True)

Exit Select



End Select

Return (MyBase.ProcessCmdKey(msg, keyData))

End If



End Function




but just like the onkeydown code it is showing e.keycode as Contrlkey {17}



I've tried intercepting the keydown in the tabcontrol and tabpage but don't seem to have that figure out either.



It is definitely a problem with the tabcontrol (or page) catching the keystroke before it hits the Ultragrid but I'm in over my head on the process of events.



w00t



Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Sorry Ivan, I'm being an idiot. i went back to the original thread and saw the code you posted about processcmdkey.



I'll work with that and hopefully I can have this working by the time you get back to the office Blush

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Well, no joy so far. ProcessCmdKey gets the same results. I also have not been able to get to work using a panel manager instead of TabControl.



I think I need to subclass the TabControl and let the ctrl-TAB pass through to the grid as some of the other Ctrl combinations do ( my cntl-Delete I created works fine - Ctrl-E does not ) I thought it might be in the SF TabControl but there is no code in the SF controls handling keystrokes.



I have tried overriding ProcessCmdKey at the tabcontrol level to just return and not call the baseclass if the key combo is ctrl-tab but that doesn't work



The processcmdkey on the baseform still sees the the TAB as controlkey if it is combined with control ( just as the onkeydown does )



I'm really stuck and the interface pretty much depends on this working ( have a question up on Stackoverflow but no answers yet ) w00t



Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Yeah, I have been playing with it a lot too, but it is quite difficult to control this situation.

Anyway, I got a bit near... since you've got Infragistics, I used the UltraTabControl instead, and the reason was that I could set a mneumonic to its tab names, like Tab&1, Tab&2, which will show Tab1, Tab2. I also set the TabStop for the control as False. This way, you could tell your users that they need to Alt+1, Alt+2 and so on, using the mneumoics you assigned to the Tabs, to get them focused, and then the Tab key would allow them to navigate inside the controls you drop in each page, your UltraGrid for instance. To get out of them, they Alt+X the page again and use the ****+Tab to go to the previous control, and then Tab through the other controls outside the UltraTabControl as they wish...

What about that? w00t

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hey, the **** should be  S h i f t ... but I might have spelt it wrongly. BigGrin
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Not sure I understand. Moving between tab pages isn't the problem. I just need to subclass the tab control to completely ignore key input just as the form does, no? I will look at the ultratab to see if I can turn it off there.



Somewhere a tabcontrol is handling control tab and I think all I need to do is convince it to ignore it.



I'll read your reply over a couple of times to see if I'm getting it but I may end up just finding a combination that is *not* blocked by tabcontrol and using that. So far I know ctrl-tab and ctrl-E won't work.



Maybe Stackoverflow will come to the rescue ...



It just seems it should be easier than this, given the granular control we have over most of the .net events.



Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
BigGrinBigGrinBigGrinBigGrinBigGrinBigGrinBigGrin



Actually, it is kind of easy. ( or at least the 90% I have so far is )



First, the ctrl-tab handled by the tabcontrol has to be disabled. In the subclass of TabControl :



Public Class MyTabControl

Inherits MicroFour.StrataFrame.UI.Windows.Forms.TabControl



Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)

If e.KeyCode = Keys.Tab AndAlso e.Control Then

e.Handled = False

e.SuppressKeyPress = False

Else

MyBase.OnKeyDown(e)

End If



End Sub

End Class




This allows the cntrl-tab to fire in the Ultragrid and to actually leave the grid and the groupbox. The problem is, I can't tell where it goes next. the next control doesn't get focus, but tab again and the control after that gets focus, so it did honor the tab order but somehow lost energy for focusing.



But if I explicitly call the focus() of that next control in the tab order in groupbox.leave everything is good.



Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

Me.grdCustomers.Focus()

End Sub



Private Sub GroupBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles GroupBox1.Leave

Me.Textbox2.Focus()

End Sub





For now, this will work, though I want to make it generic and actually have a subclassed groupbox that knows how to set focus to its contained ultragrid on Enter and set focus to the next control according to the TabOrderController on Leave.



I'll be working on it more but here is it so far





Attachments
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Brilliant, Charles! Great to hear you got it working. Wink
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