Trouble understanding changesl from vb6 to .net ... how do you...

  • Thread starter Thread starter Support
  • Start date Start date
S

Support

Hello:

What replaces "locking" a text or "combo" box so that input is not allowed?
Do not want to use disable.



How can you trap all keyboard input and set it equal to nothing?



Thanks

Terry
 
Terry,
What replaces "locking" a text or "combo" box so that input is not allowed?
Do not want to use disable

Try the .ReadOnly property.
How can you trap all keyboard input and set it equal to nothing?

Not quite sure I understand what you're trying to do here. If developing a
windows form you can capture the keypress event. Something like the
following:

Private Sub frmMyForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AddHandler somecontrol.KeyPress, AddressOf CheckMyKeyPress
End Sub

Private Sub CheckMyKeyPress(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs)

Select Case Asc(e.KeyChar)
Case AscW(ControlChars.Cr) 'Enter key
txtStatus.Text = "You Pressed The Enter Key"
Case Else ' Everything else
Exit Sub
End Select
End Sub

HTH,

Raymond Lewallen
 
In the event for keypress, you can set e.Handled = True, and the keypress will be ignored. If you want this to apply to the whole form (which would prevent any keyed input) you could set the key preview for the form to true and use something like the following

frm_Keypress(ByVal e as KeyPressEventArgs) Handles ..etc.
e.Handled = Tru
 
Back
Top