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

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
 
R

Raymond Lewallen

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top