Solved

Refresh Datagridview from another form

Posted on 2016-11-09
1
61 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

696 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