i have a class and a method that fill a listview with database records.when i call the method in form load it not works without any error.
but when i write method body in form load it works.i need to write this method and use it from another class.what should i do?
class accountinfo_show
{
public void main_list()
{
frm_main frm1 = new frm_main(); //object of main form
databaseDataContext db = new databaseDataContext();
var query = db.accountinfos;
for (int i = 0; i < query.Count(); i++)
{
var field = db.accountinfos.Where(c => c.id == i + 1).Single();
ListViewItem item = new ListViewItem(field.bankname.ToString());
item.SubItems.Add(field.banklocation.ToString());
item.SubItems.Add(field.accountnumber.ToString());
item.SubItems.Add(field.mojoodi.ToString());
frm1.lstv_main.Items.Add(item); //lstv=listview
}
}
}
in form load of frm_main i call main_list.
thanks