1
Answer

refreshing windows form- need help urgently

sairam

sairam

15y
3.4k
1

Hi

I have two windows forms form1 and form2.

Form 1 has a list box and few other controls. The data in the list box is binded from a table in a database.

I also created a method called refresh_listbox in which we have the code to bind the data from the DB again.

it is written as follows.

public void refresh_listbox()

{

code.............

}

form 2 has a textbox txtlist and a button btnsave. when i enter some text in textbox and click on btn save, it updates the field in the DB.

My question is when i clcik btnsave, it has to do the following.

1. Update the field in DB. [ I DID THIS]

2.then it should refresh the listbox in form1. I tried using some code but it is not working.

the code in form2 is as follows

## code in btn2

i declared form 1 object as frmlistbox.

my code is

frmlistbox = new form1();

frmlistbox.refresh_listbox();

is the underlined code correct or incorrect?

if it is incorrect, can some one help me how to refresh form1

 

thanks

Answers (1)