Skip to content

Invoking a method of one form from another at the same time

Basu Biswas

Asked Mar 20, 2007, 10:10 PM EDT1 answer
Share
LinkedInX

I am developing an application which displays files and folders in a listview like our Desktop. User can select as many items from the listview and delete .

I want to delete the items with a progress bar like our desktop. For that I am keeping all the selected items in an arraylist and passed that arraylist to another small form having progress bar. In this form I am deleting the items in separate thread from the database and after complition I am loading the listview with new items.

Its working fine.

Now what I want is that as the progress bar shows one items gets deleted the same item  
should be removed from the main form at the same time . As like our desktop .

Now since here I have two forms . One form is actually deleting the items from the database with a progress bar . I need some way to invoke some method in my main form which will keep removing the items from the listview at the same time.

How can i invoke a method of one form from another form.

If we see our windows as progress bar shows items getting deleted the actual items from the listview also keeps removing...

plz help...

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Mike Gold
    0
    since it's being done in another thread on the other form, I would consider creating a user event that you fire on the main form every time you delete an item from the child form. 

    Otherwise (another option) you'll need to create a delegate on the mainform and use Invoke or BeginInvoke so as not to step on the Windows Thread.  You'll need to pass a this reference from the mainform to the child form so the child form knows how to call invoke on the main form.
    0