[RESOLVED] Calling MDI Child Sub
Hi
I have a MDIParent Form named "frm_discipulus.vb" which opens a MDIChild Form named "frm_gestionare_cursanti.vb"
Code:
Private Sub tsm_cursanti_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsm_cursanti.Click
Me.Cursor = Cursors.WaitCursor
Dim frm_mdi_gestionare_cursanti As New frm_gestionare_cursanti
frm_mdi_gestionare_cursanti.MdiParent = Me
frm_mdi_gestionare_cursanti.Show()
frm_mdi_gestionare_cursanti.txt_cautare_cursanti.Select()
frm_mdi_gestionare_cursanti.txt_cautare_cursanti.Focus()
Me.Cursor = Cursors.Arrow
End Sub
On MDIChild "frm_mdi_gestionare_cursanti" i have:
1. A DataGridView named "dgv_note" populated by the Public Sub named "afisare_note_obtinute"
Code:
Public Sub afisare_note_obtinute()
Try
conectare_db()
data_table = New DataTable
data_adapter = New SqlClient.SqlDataAdapter("SELECT lista_note_obtinute.id, nomenclator_discipline.denumire_disciplina, lista_note_obtinute.id_clasa, lista_note_obtinute.nota_obtinuta, lista_note_obtinute.id_cursant, lista_note_obtinute.data_notei FROM lista_note_obtinute, nomenclator_discipline WHERE lista_note_obtinute.id_disciplina = nomenclator_discipline.id AND lista_note_obtinute.id_cursant='" & Me.dgv_lista_cursanti.CurrentRow.Cells(0).Value & "' AND lista_note_obtinute.id_clasa='" & Me.dgv_clase.CurrentRow.Cells(1).Value & "' ORDER BY nomenclator_discipline.denumire_disciplina;".ToString, conexiune)
command_builder = New SqlClient.SqlCommandBuilder(data_adapter)
data_adapter.Fill(data_table)
Me.dgv_note.DataSource = data_table
Dim coloana_1 As DataGridViewColumn = dgv_note.Columns(1)
Me.dgv_note.Columns(0).Visible = False
Me.dgv_note.Columns(1).HeaderText = "Disciplină"
Me.dgv_note.Columns(2).Visible = False
Me.dgv_note.Columns(3).Width = 90
Me.dgv_note.Columns(3).HeaderText = "Notă"
Me.dgv_note.Columns(4).Visible = False
Me.dgv_note.Columns(5).Width = 90
Me.dgv_note.Columns(5).HeaderText = "Din data"
coloana_1.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
deconectare_db()
Catch ex As Exception
End Try
End Sub
2. LinkLabel named "lkl_adaugare_nota" which opens a Form named "frm_adaugare_nota_cursant"
Code:
Private Sub lkl_adaugare_nota_LinkClicked(sender As System.Object, e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lkl_adaugare_nota.LinkClicked
frm_adaugare_nota_cursant.ShowDialog()
End Sub
On that form (frm_adaugare_nota_cursant) users had to input some datas and after it's finishing and closing the form the data must be visible on MDIChild DataGridView.
I have tried to call the "Public Sub frm_gestionare_cursanti()" by using the code
Code:
frm_gestionare_cursanti.afisare_note_obtinute()
And nothing hapends.
Why ?
What shold i do to refresh the DGV on MDIChild?
Re: Calling MDI Child Sub
don't call it from you other form... call it from the LinkClicked event:
Code:
Private Sub lkl_adaugare_nota_LinkClicked(sender As System.Object, e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lkl_adaugare_nota.LinkClicked
frm_adaugare_nota_cursant.ShowDialog()
afisare_note_obtinute()
End Sub
-tg
Re: Calling MDI Child Sub
I must admit I am stupid
Thanks techgnome!