Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Refresh Datagridview from another form

Posted on 2016-11-09
1
Medium Priority
?
89 Views
Last Modified: 2016-11-10
Hi,

I have two forms. I call FORM2 from FORM1. When in FORM2 and apply some changes with button control i need refresh Datagridview in FORM1 before exit FORM2.


Call FORM2 from FORM1:

Dim f As New form2(myparameter)
f.ShowDialog()

Code for Button in FORM2:

 Dim f1 As New form1
 F1.ShowGridRecords()  ' Procedure to bind grid
 f1.MyDgView.Refresh()

But with this approach not work, can someone help.

best regards

Example in attached image
img6.png
0
Comment
Question by:rflorencio
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
Dustin Saunders earned 2000 total points
ID: 41880993
You would need to create an event on the sub form that the parent would subscribe to.  When that event is triggered on the the sub form, then you can trigger a refresh method.

Here is an example:
'Here is the code for parent form
Public Class ParentFormClass
    Public Sub MyLogic()
        MessageBox.Show("My Logic is Running!")
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MyLogic()
    End Sub    

    'This is the way that you pass an instance of parent to child
    Private Sub ShowChildFormButton_Click(sender As Object, e As EventArgs) Handles ShowChildFormButton.Click
        Dim f As New ChildFormClass(Me)
    End Sub
End Class

'Here is the code for child form
Public Class ChildFormClass
    Private MyParentForm As ParentFormClass

    Public Sub New(form As ParentFormClass)
        ' This call is required by the designer.
        InitializeComponent()
        ' Add any initialization after the InitializeComponent() call.
        MyParentForm = form
    End Sub

    Private Sub CallParentFormMethodButton_Click(sender As Object, e As EventArgs) Handles CallParentFormMethodButton.Click
        MyParentForm.MyLogic()
    End Sub 
End Class

Open in new window

via http://stackoverflow.com/questions/33383171/how-can-i-trigger-parent-form-event-from-child-form
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question