We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How Can i detetct Return in datagrid Cell

Hi, Please I need help. I created a form that allows me searching customers by name. after display customers list in datagrid, i want allow user to select one customer by pressing key. for grid setup, i tried the following code : 'Configuration de la grille Private Sub DataGridSetup() Dim ts As New DataGridTableStyle() Dim cs As New DataGridTextBoxColumn() AddHandler cs.TextBox.KeyPress, AddressOf CellKeyPress DataGrid1.ContextMenu = ContextMenu1 DataGrid1.CaptionText = "Résultat" ts.MappingName = "mycli" cs.MappingName = "c_cli" cs.HeaderText = "Code" cs.Alignment = HorizontalAlignment.Center ts.GridColumnStyles.Add(cs) cs = New DataGridTextBoxColumn() cs.MappingName = "N_cli" cs.HeaderText = "Nom/Raison sociale" ts.GridColumnStyles.Add(cs) DataGrid1.TableStyles.Clear() DataGrid1.TableStyles.Add(ts) End Sub and i added handler to datagridtextboxcolumn, for detecting the keypress events as follows : 'Ajout d'un évènement aux cellules Public Sub CellKeyPress(ByVal Sender As Object, ByVal e As KeyPressEventArgs) Dim dt As DataTable = ds.Tables("mycli") Dim p As Integer CodeClient = Space(11) If e.KeyChar = Chr(13) Then p = Me.BindingContext(ds, "mycli").Position CodeClient = dt.Rows(p)("c_cli") Me.Close() End If End Sub So after writing this code, i can select one customer only after pressing SHIFT+RETURN. please can you explain me way i must first press SHIFT. Thank you very match. Intibnin...

1 Reply

SK Shardool Karnik December 17, 2002 05:14 PM UTC

Maybe because return by itself moves through the cells ??? > Hi, > Please I need help. > I created a form that allows me searching customers by name. after display customers list in datagrid, i want allow user to select one customer by pressing key. > for grid setup, i tried the following code : > > 'Configuration de la grille > Private Sub DataGridSetup() > Dim ts As New DataGridTableStyle() > Dim cs As New DataGridTextBoxColumn() > AddHandler cs.TextBox.KeyPress, AddressOf CellKeyPress > DataGrid1.ContextMenu = ContextMenu1 > DataGrid1.CaptionText = "Résultat" > ts.MappingName = "mycli" > cs.MappingName = "c_cli" > cs.HeaderText = "Code" > cs.Alignment = HorizontalAlignment.Center > ts.GridColumnStyles.Add(cs) > cs = New DataGridTextBoxColumn() > cs.MappingName = "N_cli" > cs.HeaderText = "Nom/Raison sociale" > ts.GridColumnStyles.Add(cs) > DataGrid1.TableStyles.Clear() > DataGrid1.TableStyles.Add(ts) > End Sub > > and i added handler to datagridtextboxcolumn, for detecting the keypress events as follows : > > 'Ajout d'un évènement aux cellules > Public Sub CellKeyPress(ByVal Sender As Object, ByVal e As KeyPressEventArgs) > Dim dt As DataTable = ds.Tables("mycli") > Dim p As Integer > CodeClient = Space(11) > If e.KeyChar = Chr(13) Then > p = Me.BindingContext(ds, "mycli").Position > CodeClient = dt.Rows(p)("c_cli") > Me.Close() > End If > > End Sub > > > So after writing this code, i can select one customer only after pressing SHIFT+RETURN. > > please can you explain me way i must first press > SHIFT. > > Thank you very match. > > Intibnin... > > >

Loader.
Live Chat Icon For mobile
Up arrow icon