Vikas Ahlawat

Vikas Ahlawat

  • NA
  • 564
  • 817.8k

how pass list<> from one form to another in C# winform?

Jun 7 2012 12:42 AM


I have the following list on DisplayRooms form and same list(but not static) on the  WalkinGuest form.

public static List<Room> RoomList

{get;set;}

public class Room

   {

            public int RoomID { get; set; }

            public string RoomNumber { get; set; }

            public string RoomType { get; set; }

   }


List<Room> RoomsList = new List<Room>();

...

..

Now after insert data in RoomList I pass it to showwalkinform method then its give error..


showwalkinForm(RoomList);

private void showwalkinForm(List<Room> Rooms)

        {

            IxSolutionSuite.Forms.MDIMaster omdi = IxSolutionSuite.Forms.MDIMaster.Instance;

            WalkinGuest oFrmWalkinGuest = WalkinGuest.Instance;

            oFrmWalkinGuest.RoomList = (List<WalkinGuest.Room>)Rooms; //here it gives error:- can't convert type ... to ...

            oFrmWalkinGuest.Show();

            oFrmWalkinGuest.Focus();

        }

Can any one tell help me to solve this problem..


Answers (10)