IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

Bouton deroulant datagridview


Sujet :

VB.NET

  1. #1
    Nouveau membre du Club Avatar de paradize99
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2019
    Messages
    60
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 26
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2019
    Messages : 60
    Points : 29
    Points
    29
    Par défaut Bouton deroulant datagridview
    Bonjour,
    J'ai crée un datagridview que j'ai réussi à remplir seulement j'aimerais rajouter un bouton déroulante dans une nouvelle colonne et j'arrive pas à trouver d'informations sur internet.
    Pour que ce soit plus claire, voici un exemple
    Nom : bouton.PNG
Affichages : 281
Taille : 3,0 Ko

    L'objectif est d'aboir une ligne avec un bouton et quand on appuie on obtient d'autres lignes
    Merci d'avance pour vos réponses

  2. #2
    Membre émérite Avatar de Phil Rob
    Homme Profil pro
    Retraité
    Inscrit en
    Novembre 2013
    Messages
    1 613
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Novembre 2013
    Messages : 1 613
    Points : 2 865
    Points
    2 865
    Par défaut
    Salut,

    Voici tout ce que j'ai sur la question :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
      Private Sub FBase_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     
            Dim ColPrecio As New DataGridViewComboBoxColumn()
            ColPrecio.HeaderText = "Precio"
            ColPrecio.Name = "Precio"
     
            ColPrecio.Items.Add("1")
            ColPrecio.Items.Add("2")
            ColPrecio.Items.Add("3")
     
            MiDGV.Columns.Add("Cantidad", "Cantidad")
            MiDGV.Columns.Add("Producto", "Producto")
            MiDGV.Columns.Add(ColPrecio)
            MiDGV.Columns.Add("Total", "Total")
     
            MiDGV.Rows.Add("2", "Prod.1")
            MiDGV.Rows.Add("5", "Prod.2")
            MiDGV.Rows.Add("10", "Prod.3")
     
        End Sub
     
        Private Sub MiDGV_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles MiDGV.CellValueChanged
            If MiDGV.Rows.Count < 1 Then
                Exit Sub
            End If
     
            MiDGV.Item(MiDGV.Columns("Total").Index, e.RowIndex).Value =
                MiDGV.Item(MiDGV.Columns("Cantidad").Index, e.RowIndex).Value *
                MiDGV.Item(MiDGV.Columns("Precio").Index, e.RowIndex).Value
     
        End Sub
    Nom : DGVCombo.jpg
Affichages : 265
Taille : 16,5 Ko

    J'espère que ça t'aidera ...

  3. #3
    Nouveau membre du Club Avatar de paradize99
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2019
    Messages
    60
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 26
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2019
    Messages : 60
    Points : 29
    Points
    29
    Par défaut
    Merci pour ta reponse mais c'est pas ce que je recherche. Ce que j'aimerais c'est ce quand j'appuie je puisse afficher des textbox

    Nom : bouton2.PNG
Affichages : 263
Taille : 2,3 Ko

    Je sais que c'est possible sur VBA

  4. #4
    Nouveau membre du Club Avatar de paradize99
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2019
    Messages
    60
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 26
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2019
    Messages : 60
    Points : 29
    Points
    29
    Par défaut
    Pour ce que ca interesse, au final j'ai cree un bouton qui ouvre un form en function de la ligne

  5. #5
    Membre émérite Avatar de Phil Rob
    Homme Profil pro
    Retraité
    Inscrit en
    Novembre 2013
    Messages
    1 613
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Novembre 2013
    Messages : 1 613
    Points : 2 865
    Points
    2 865
    Par défaut
    Et quoi, ton bouton, il est intégré au DGV ? Je veux bien voir ...

  6. #6
    Nouveau membre du Club Avatar de paradize99
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2019
    Messages
    60
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 26
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2019
    Messages : 60
    Points : 29
    Points
    29
    Par défaut
    desole je l'ai pas avec moi mais pour l'instant j'ai cree un bouton lie a la ligne du dgv

  7. #7
    Nouveau membre du Club Avatar de paradize99
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2019
    Messages
    60
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 26
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2019
    Messages : 60
    Points : 29
    Points
    29
    Par défaut
    Alors j'ai cree un bouton relie a la ligne selectionnee du dgv sur le form1 et sur le form 2 j'ai 3 Textbox dependant de ma database et des valeurs du dgv du form1

    Form1
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
        Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
     
            If DataGridView1.Visible = True Then
                Dim i As Integer
                i = DataGridView1.CurrentCell.RowIndex
                Notes.TextBox4.Text = DataGridView1.Rows(i).Cells(1).Value.ToString
                Notes.TextBox5.Text = DataGridView1.Rows(i).Cells(4).Value.ToString
                Notes.TextBox6.Text = DataGridView1.Rows(i).Cells(6).Value.ToString
                Notes.Show()
     
            ElseIf DataGridView2.Visible = True Then
                Dim i As Integer
                i = DataGridView2.CurrentCell.RowIndex
                Notes.TextBox4.Text = DataGridView2.Rows(i).Cells(2).Value.ToString
                Notes.TextBox5.Text = DataGridView2.Rows(i).Cells(4).Value.ToString
                Notes.TextBox6.Text = DataGridView2.Rows(i).Cells(6).Value.ToString
     
                Notes.Show()
     
            End If
    Form Notes
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
        Private Sub Notes_Load(sender As Object, e As EventArgs) Handles MyBase.Load
     
            Dim ds As New DataSet
            Dim cmd As New OleDbCommand("select * from tblToolRequisition where RequistionNum='" & TextBox4.Text & "' AND PN='" & TextBox5.Text & "'AND ToolDRG='" & TextBox6.Text & "'", cn)
     
            Dim da As New OleDbDataAdapter(cmd)
            da.Fill(ds, "tblToolRequisition")
            cn.Open()
            Dim dr As OleDbDataReader = cmd.ExecuteReader
     
            While dr.Read()
                TextBox1.Text = dr(27).ToString
                TextBox2.Text = dr(18).ToString
                TextBox3.Text = dr(17).ToString
            End While
     
            dr.Close()
            cn.Close()
    Pour l'instant y a juste une erreur pour rafraichir mais j'y travaille donc je met le bon code des que je trouve

  8. #8
    Membre émérite Avatar de Phil Rob
    Homme Profil pro
    Retraité
    Inscrit en
    Novembre 2013
    Messages
    1 613
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Novembre 2013
    Messages : 1 613
    Points : 2 865
    Points
    2 865
    Par défaut
    Merci à toi de partager ce travail.
    Pour ton rafraichissement, il faudrait préciser le problème ... "on" pourrait peut-être y réfléchir.
    En principe, le Form actif peut modifier en temps réel l'autre Form. Mais attention, il ne convient pas de refaire le Show sous Button10 à chaque changement de donnée.
    Form2 étant ouvert, et Form1 recevant le focus, une modif dans Form1 doit être visible sur Form2.
    Je dois avoir un extrait de cours concernant les communications entre Form, je le chercherai demain ...
    Bonne soirée,

  9. #9
    Membre émérite Avatar de Phil Rob
    Homme Profil pro
    Retraité
    Inscrit en
    Novembre 2013
    Messages
    1 613
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Novembre 2013
    Messages : 1 613
    Points : 2 865
    Points
    2 865
    Par défaut
    Voila, ci-joint ComunicacionEntreFormsFR.zip qui contient un dossier de projet pour les tests du minimum nécessaire en matière de communication entre Form. Tu trouveras aussi le fichier ComunicacionEntreFormsFR.pdf qui contient un résumé comparatif des méthodes utilisées dans le projet.
    Peut-être as-tu déjà eu ces documents (je vois qu'il s'agit d'une traduction de début février) mais c'est tout ce que j'ai ...
    Bonne lecture,
    Images attachées Images attachées
    Fichiers attachés Fichiers attachés

  10. #10
    Nouveau membre du Club Avatar de paradize99
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2019
    Messages
    60
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 26
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2019
    Messages : 60
    Points : 29
    Points
    29
    Par défaut
    Merci pour la documentation Phil Rob

    J'ai reussi a trouver comment faire pour eviter les problemes de refresh en mettant le code pour remplir les textbox du form Notes directement dans le form Main

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
                Dim i As Integer
                i = DataGridView1.CurrentCell.RowIndex
                Notes.TextBox4.Text = DataGridView1.Rows(i).Cells(1).Value.ToString
                Notes.TextBox5.Text = DataGridView1.Rows(i).Cells(4).Value.ToString
                Notes.TextBox6.Text = DataGridView1.Rows(i).Cells(6).Value.ToString
     
                Notes.Show()
     
                ' remplissage textbox
                Dim ds As New DataSet
                Dim cmd As New OleDbCommand("select * from tblToolRequisition where RequistionNum='" & Notes.TextBox4.Text & "' AND PN='" & Notes.TextBox5.Text & "'AND ToolDRG='" & Notes.TextBox6.Text & "'", cn)
     
                Dim da As New OleDbDataAdapter(cmd)
                da.Fill(ds, "tblToolRequisition")
                cn.Open()
                Dim dr As OleDbDataReader = cmd.ExecuteReader
     
                While dr.Read()
                    Notes.TextBox1.Text = dr(27).ToString
                    Notes.TextBox2.Text = dr(18).ToString
                    Notes.TextBox3.Text = dr(17).ToString
                End While
                dr.Close()
                cn.Close()
    dans le form Notes j'ai uniquement la commande du bouton Save

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
        Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
     
            cn.Open()
            Dim Update As New OleDbCommand("UPDATE tblToolRequisition SET ToolNotes='" & TextBox1.Text & "', EngineeringNotes='" & TextBox2.Text & "', ProductionNotes='" & TextBox3.Text & "'", cn)
            Update.ExecuteNonQuery()
            cn.Close()
            Me.Hide()
     
        End Sub
    En esperant que ca aidera quelqu'un

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Colonne de bouton dans Datagridview
    Par jubourbon dans le forum Windows Forms
    Réponses: 1
    Dernier message: 25/01/2010, 18h30
  2. desactiver un menu deroulant si le radio bouton n'est pas actif
    Par floppy__ dans le forum Général JavaScript
    Réponses: 8
    Dernier message: 23/10/2007, 19h39
  3. Clignotement de bouton dans menu deroulant
    Par guillaumeabxl dans le forum Flash
    Réponses: 1
    Dernier message: 15/10/2007, 16h53
  4. Clignotement de bouton dans menu deroulant
    Par guillaumeabxl dans le forum Intégration
    Réponses: 2
    Dernier message: 15/10/2007, 11h51
  5. [FLASH 8] Transition sur bouton de menu deroulant
    Par chienlou dans le forum Flash
    Réponses: 3
    Dernier message: 05/06/2006, 10h13

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo