Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

Sign in to follow this  
PMSF

[Resolvido] KeyPress no DataGridView

Recommended Posts

PMSF

bom dia,

estou com dificuldade em aplicar o KeyPress dentro do DataGridView.

o que pretendo é que quando o utilizador carrega na tecla "." passe para ","

para isto já tenho o código, mas devia estar associado ao evento KeyPress mas não funciona...

alguém sabe como resolver?!

obrigado

Share this post


Link to post
Share on other sites
PMSF

quando estou a escrever dentro da célula o evento KeyDown tambem não é chamado...

:(

Edited by PMSF

Share this post


Link to post
Share on other sites
PMSF

depois de uma manhã chata descobri após pesquisar na net...

então temos que usar o evento:


Public Class Form1

Private Sub DataGridView1_EditingControlShowing(sender As System.Object, e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
Dim c As Control
c = e.Control

AddHandler c.KeyPress, AddressOf Handle_KeyPress


End Sub

Protected Sub Handle_KeyPress(sender As Object, e As KeyPressEventArgs)
If Char.IsLetterOrDigit(e.KeyChar) Then
TextBox1.Text += e.KeyChar
e.Handled = True
End If
End Sub
End Class

assim já me funciona :) depois de adaptar ao que quero ...

Edited by apocsantos

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.