Results 1 to 3 of 3

Thread: [RESOLVED] Calling MDI Child Sub

  1. #1

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Resolved [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?
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: Calling MDI Child Sub

    I must admit I am stupid

    Thanks techgnome!
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width