Abolfazl

Abolfazl

  • 1.5k
  • 184
  • 78.7k

problem in call a method from class

Mar 24 2014 5:31 AM
hi
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?
it's class and method code:
 
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 
 

Answers (4)