Hi everyone, I have a form with many controls and i am using VB Net(2003)
The major control are 1-TreeView, 2-DataGrid, 3- ListView
Upon the click on the treeview category it fill a datagrid with 4 columns and many rows, since i have about at least 30 differents categories i have 30 differents images of datagrid, up to here all is fine. Here is my problem What I want to do is when I double-click on a row from the datagrid is to copy the full row(4Col.) to the listView control and keep adding rows every time a new double-click is done .An example code would be greatly apreciated Thankyou in advance. Andy38
Here part of my code
Private Sub se_connecter(ByVal requete As String, ByVal table As String)
Dim base, chemin As String
'Chemin d'accès à la b.d. située dans le dossier bin
'chemin = "D:\Projet_Vb\TreeView20dec\Invetaire.mdb"
chemin = Application.StartupPath & "\Inventaire.mdb"
base = "provider=microsoft.jet.oledb.4.0;data source=" + chemin
Dim connexion As OleDbConnection = New OleDbConnection(base)
connexion.Open()
'Lien entre la base et la requête
Dim Liaison As New OleDbDataAdapter(requete, base)
Dim Memoire As New DataSet
'Charge la table en mémoire
Liaison.Fill(Memoire, table)
Dim Vue As New DataView(Memoire.Tables(table))
grille.DataSource = Vue
connexion.Close()
End Sub
Private Sub oTv_AfterSelect(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.TreeViewEventArgs) _
Handles oTv.AfterSelect
Dim node As System.Windows.Forms.TreeNode
Lb1Path.Text = oTv.SelectedNode.FullPath
'MessageBox.Show(oTv.SelectedNode.ToString)
Dim requete, table As String
'Sélectionne tout
requete = "SELECT * FROM Produits WHERE CATEGORIE = '" & Lb1Path.Text & "'"
table = "Produits"
se_connecter(requete, table)
If Not (e.Node Is Nothing) Then
g_bState_NodeSelected = True
Else
g_bState_NodeSelected = False
End If
SetUIState(g_bState_NodesPresent, g_bState_NodeSelected, g_bState_NodesDirty)
End Sub
'select entire row if a cell is selected:
Private Sub dataGrid1_MouseUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles grille.MouseUp
Dim pt As Point = New Point(e.X, e.Y)
Dim hti As DataGrid.HitTestInfo = grille.HitTest(pt)
If hti.Type = DataGrid.HitTestType.Cell Then
grille.CurrentCell = New DataGridCell(hti.Row, hti.Column)
grille.Select(hti.Row)
End If
End Sub
The major control are 1-TreeView, 2-DataGrid, 3- ListView
Upon the click on the treeview category it fill a datagrid with 4 columns and many rows, since i have about at least 30 differents categories i have 30 differents images of datagrid, up to here all is fine. Here is my problem What I want to do is when I double-click on a row from the datagrid is to copy the full row(4Col.) to the listView control and keep adding rows every time a new double-click is done .An example code would be greatly apreciated Thankyou in advance. Andy38
Here part of my code
Private Sub se_connecter(ByVal requete As String, ByVal table As String)
Dim base, chemin As String
'Chemin d'accès à la b.d. située dans le dossier bin
'chemin = "D:\Projet_Vb\TreeView20dec\Invetaire.mdb"
chemin = Application.StartupPath & "\Inventaire.mdb"
base = "provider=microsoft.jet.oledb.4.0;data source=" + chemin
Dim connexion As OleDbConnection = New OleDbConnection(base)
connexion.Open()
'Lien entre la base et la requête
Dim Liaison As New OleDbDataAdapter(requete, base)
Dim Memoire As New DataSet
'Charge la table en mémoire
Liaison.Fill(Memoire, table)
Dim Vue As New DataView(Memoire.Tables(table))
grille.DataSource = Vue
connexion.Close()
End Sub
Private Sub oTv_AfterSelect(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.TreeViewEventArgs) _
Handles oTv.AfterSelect
Dim node As System.Windows.Forms.TreeNode
Lb1Path.Text = oTv.SelectedNode.FullPath
'MessageBox.Show(oTv.SelectedNode.ToString)
Dim requete, table As String
'Sélectionne tout
requete = "SELECT * FROM Produits WHERE CATEGORIE = '" & Lb1Path.Text & "'"
table = "Produits"
se_connecter(requete, table)
If Not (e.Node Is Nothing) Then
g_bState_NodeSelected = True
Else
g_bState_NodeSelected = False
End If
SetUIState(g_bState_NodesPresent, g_bState_NodeSelected, g_bState_NodesDirty)
End Sub
'select entire row if a cell is selected:
Private Sub dataGrid1_MouseUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles grille.MouseUp
Dim pt As Point = New Point(e.X, e.Y)
Dim hti As DataGrid.HitTestInfo = grille.HitTest(pt)
If hti.Type = DataGrid.HitTestType.Cell Then
grille.CurrentCell = New DataGridCell(hti.Row, hti.Column)
grille.Select(hti.Row)
End If
End Sub