3 pièce(s) jointe(s)
afficher sur le combo la situation d'un enregistrement en vue d'une modification
Bonjour à tous ;
Je vous remercie d'avance pour l'aide précieuse que vous m'apporterez.
L’image ci-dessous est mon formulaire d'affichage de donnée en vue d'une éventuelle modification.
En effet, lors du click sur le bouton modifier, les infos sélectionné du DataGridView (première image) doivent être tranféré au formulaire de modification (seconde image)
Pièce jointe 573147
Pièce jointe 573148
Sauf que quand j'affecte les valeurs récupérées, la date et le montant sont corrects, mais pour les combos box dans SelectedItem ou SelectedValue ou encore SelectedText, le combo n'affiche pas la valeur voulue (celle de l'enregistrement mais plutôt la valeur initiale.
Code:
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
Private Sub btn_modify_operation_Click(sender As Object, e As EventArgs) Handles btn_modify_operation.Click
connex.Close()
connex.Open()
Dim form As New Frm_Modification
Dim i, mont As Integer
Dim dateop, op, mot, motsup, dev As String
i = grid_story.CurrentRow.Index
req1 = "SELECT num_operation AS NUM, date_operation AS DATES, designation_operation, designation_motif,designation_departement, designation_bien, devise_operation AS DEVISES, FORMAT(montant_operation, 2) AS MONTANTS FROM tab_operation, tab_type_operation, tab_motif, tab_departement, tab_bien_vendu WHERE tab_type_operation.type_operation=tab_operation.operation AND tab_motif.type_operation=tab_operation.operation AND tab_motif.motif=tab_operation.motif_operation AND tab_operation.departement_operation=tab_departement.departement AND tab_operation.bien_vendu_operation=tab_bien_vendu.code_bien AND tab_operation.num_operation='" & grid_story.Rows(i).Cells(0).Value & "' "
Dim rd5 As MySqlDataReader
Dim cmd8 As New MySqlCommand(req1, connex)
rd5 = cmd8.ExecuteReader
While rd5.Read
dateop = rd5("date_operation")
op = rd5("designation_operation")
mot = rd5("designation_motif")
If rd5("designation_departement") = Nothing And String.IsNullOrEmpty(rd5("designation_bien")) = False Then
motsup = rd5("designation_bien")
ElseIf rd5("designation_bien") = Nothing And String.IsNullOrEmpty(rd5("designation_departement")) = False Then
motsup = rd5("designation_departement")
ElseIf rd5("designation_bien") = Nothing And rd5("designation_departement") = Nothing Then
motsup = Nothing
End If
dev = rd5("devise")
mont = rd5("montant_operation")
End While
If user_role = "ADMIN" Or user_role = "AUTORISE" Then
form.date_operation.Value = grid_story.Rows(i).Cells(1).Value
form.cbo_operation_saisi.SelectedText = op
form.cbo_motif.SelectedText = mot
form.cbo_motif_sup.SelectedText = motsup
form.cbo_devise.SelectedText = dev
form.txt_montant.Text = grid_story.Rows(i).Cells(6).Value
Else
form.date_operation.Value = grid_story.Rows(i).Cells(1).Value
form.date_operation.Enabled = False
form.cbo_operation_saisi.SelectedItem = op
form.cbo_operation_saisi.Enabled = False
form.cbo_motif.SelectedItem = mot
form.cbo_motif.Enabled = False
form.cbo_motif_sup.SelectedItem = motsup
form.cbo_motif_sup.Enabled = False
form.cbo_devise.SelectedItem = dev
form.cbo_devise.Enabled = False
form.txt_montant.Text = grid_story.Rows(i).Cells(5).Value
form.txt_montant.Enabled = False
form.btn_save.Visible = False
End If
form.Show() |
Et quand la modification est fini, la propriété Refresh ou Update ne marche pas sur le DataGridView
Que puis-je faire pour contourner cette tuile?!
P-S: j'ai essayé la méthode SelectedIndex en affectant comme index, la valeur résultante du calcul (Primary key de la donnée à afficher - 1) mais cela ne marche toujours pas.