Click here to Skip to main content
15,889,992 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Securing Local Files [Solved] Pin
Saul Johnson5-Sep-12 4:03
Saul Johnson5-Sep-12 4:03 
GeneralRe: Securing Local Files [Solved] Pin
ObiWan_MCC5-Sep-12 4:36
ObiWan_MCC5-Sep-12 4:36 
QuestionArrow keys to move an object Pin
Steven St. John1-Sep-12 11:30
Steven St. John1-Sep-12 11:30 
AnswerRe: Arrow keys to move an object Pin
ChandraRam2-Sep-12 23:57
ChandraRam2-Sep-12 23:57 
GeneralRe: Arrow keys to move an object Pin
Steven St. John3-Sep-12 3:35
Steven St. John3-Sep-12 3:35 
GeneralRe: Arrow keys to move an object Pin
ChandraRam3-Sep-12 4:00
ChandraRam3-Sep-12 4:00 
GeneralRe: Arrow keys to move an object Pin
Steven St. John3-Sep-12 7:25
Steven St. John3-Sep-12 7:25 
AnswerRe: Arrow keys to move an object Pin
Alan N3-Sep-12 6:00
Alan N3-Sep-12 6:00 
The MSDN documentation for the KeyPreview property isn't exactly clear http://msdn.microsoft.com/en-us/library/system.windows.forms.form.keypreview.aspx[^]. It starts off with the statement that the form will receive all KeyXXXX events from the focussed control, but then adds a note that some controls may cancel a keystroke and disable the preview.

There is short thread on stackoverflow[^] which I think you will find interesting. In one of the answers, Hans Passant describes overriding the form's ProcessCmdKey method as a better solution, e.g.
VB
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean
  If activeBrick IsNot Nothing Then
    If keyData = Keys.Down OrElse keyData = Keys.Up Then
      MoveBrick(keyData)
      Return True
    End If
  End If
  Return MyBase.ProcessCmdKey(msg, keyData)
End Function


A quick test suggests that this is much more useful technique than KeyPreview and it does not rely on the uncertain cooperation of the focussed control.

Alan.
GeneralRe: Arrow keys to move an object Pin
Steven St. John3-Sep-12 7:32
Steven St. John3-Sep-12 7:32 
AnswerRe: Arrow keys to move an object Pin
Sonhospa3-Sep-12 7:14
Sonhospa3-Sep-12 7:14 
GeneralRe: Arrow keys to move an object Pin
Steven St. John3-Sep-12 7:35
Steven St. John3-Sep-12 7:35 
GeneralRe: Arrow keys to move an object Pin
Sonhospa3-Sep-12 21:30
Sonhospa3-Sep-12 21:30 
QuestionDataContext Not Updating Its Database Pin
Sonhospa31-Aug-12 23:16
Sonhospa31-Aug-12 23:16 
AnswerRe: DataContext Not Updating Its Database Pin
Sonhospa3-Sep-12 7:21
Sonhospa3-Sep-12 7:21 
QuestionToggling ON/OFF VB6 reference library in Visual Studio Pin
juno10131-Aug-12 6:27
juno10131-Aug-12 6:27 
AnswerRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
Dave Kreskowiak31-Aug-12 7:26
mveDave Kreskowiak31-Aug-12 7:26 
GeneralRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
juno10131-Aug-12 9:06
juno10131-Aug-12 9:06 
GeneralRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
Dave Kreskowiak31-Aug-12 9:26
mveDave Kreskowiak31-Aug-12 9:26 
GeneralRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
juno1011-Sep-12 17:49
juno1011-Sep-12 17:49 
GeneralRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
Dave Kreskowiak1-Sep-12 18:42
mveDave Kreskowiak1-Sep-12 18:42 
QuestionHow to insert an ID number to another table column Pin
garyu8730-Aug-12 20:56
garyu8730-Aug-12 20:56 
AnswerRe: How to insert an ID number to another table column Pin
Wayne Gaylard30-Aug-12 22:24
professionalWayne Gaylard30-Aug-12 22:24 
GeneralRe: How to insert an ID number to another table column Pin
garyu8730-Aug-12 23:09
garyu8730-Aug-12 23:09 
GeneralRe: How to insert an ID number to another table column Pin
Wayne Gaylard30-Aug-12 23:19
professionalWayne Gaylard30-Aug-12 23:19 
GeneralRe: How to insert an ID number to another table column Pin
Simon_Whale30-Aug-12 23:20
Simon_Whale30-Aug-12 23:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.