See changes (delete) on grid Vb.net

Asked

Viewed 131 times

2

Hi, I’d like you to help me with the next one. i have a form that does a search for a code with several grids and a button, this button makes a number of changes in the various grids but also want to delete a certain lines with a delete query that I created and, despite deleting me in BD (which is what I want) also wanted the lines to disappear from the grid. how do I make them disappear automatically when I click the button? is that I can only see the grid without the lines when I re-enter the code for the query. Thank you

Public Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click

    TextBox1.Text = DGV1(5, 0).Value

    Dim i As Integer
    Dim j As Integer



    ' para preencher a coluna do potencial de prescrição (id = 8 para 5), RankId(48 para Selecção)
    'Perfil linico = 8, GroupId = 8 (Categoria - Médicos) 


    For i = 0 To DGV3.Rows.Count - 1
        Select Case DGV3(2, i).Value
            Case 26
                DGV3(9, i).Value = 8
                DGV3(5, i).Value = 48
                DGV3(23, i).Value = 8
                DGV3(6, i).Value = 84

        End Select

    Next
    EscreveEnterpriseDetails()


    'para nr de clinicas


    Dim Obs As String
    Obs = Trim(DGV1(20, 0).Value.ToString)
    For j = 0 To DGV5.Rows.Count - 2

        If Obs = "" Then

            Obs = checknull(DGV5(6, j).Value.ToString) & " - " & checknull(DGV5(7, j).Value.ToString) & " - " & checknull(DGV5(8, j).Value.ToString)

        Else

            Obs = Obs & Chr(13) & Chr(10) & checknull(DGV5(6, j).Value.ToString) & " - " & checknull(DGV5(7, j).Value.ToString) & " - " & checknull(DGV5(8, j).Value.ToString)

        End If


    Next

    ' MsgBox(Obs)


    DGV1(20, 0).Value = Obs
    DGV1(13, 0).Value = 0

    EscreverDoctorBasic()



    'para a morada 
    For j = 0 To DGV5.Rows.Count - 2
        DGV5(6, j).Value = "NÃO DEFINIDO" ' para a morada
        DGV5(7, j).Value = 421705           'para o codigo postal
        DGV5(8, j).Value = 0            'para o tipo local
        DGV5(9, j).Value = ""   ' para o horário
        DGV5(10, j).Value = True   ' visto para o LocalVisita

    Next
    EscreveAddress()

    ApagarRegistos()
  • 1

    Hello Mara, Vc should call the grid again, for it to update as the database data, do this after the function that will delete the db records

  • 1

    I use Fill, that’s it?

  • this, then you assign again the values in your datagrid.

  • 1

    that’s right! Thank you!

1 answer

1

Use Fill to fill your datagrid after deleting your DB data.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.