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.
Unfortunately, activation email could not send to your email. Please try again.

How Can i detetct Return in datagrid Cell

Thread ID:

Created:

Updated:

Platform:

Replies:

2053 Dec 12,2002 07:47 AM Dec 17,2002 12:14 PM Windows Forms 1
loading
Tags: FAQ
intibnin
Asked On December 12, 2002 07:47 AM

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...

Shardool Karnik
Replied On December 17, 2002 12:14 PM

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... > > >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;