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..
VulpesPosted Jun 7, 2012, 6:17 AM
All I'm saying is that you need to use this qualified name when referrring to the Room class from outside the DisplayRooms form, so the compiler can find it. Each form that uses the List will therefore need a field of type List
It would have been better, IMO, if you'd made Room a top level class (i.e. not nested) in the same namespace as your forms. You could then simply have referred to it as 'Room' in all those forms but, if you don't want to change anything, you can't do that now.
Vikas AhlawatPosted Jun 7, 2012, 6:37 AM
VulpesPosted Jun 7, 2012, 6:29 AM
What thoughts I do have, I tend to express on here :)
Vikas AhlawatPosted Jun 7, 2012, 6:24 AM
My problem is solved thnx very much Vulpes
have you facebook account? I want to add you..
Vikas AhlawatPosted Jun 7, 2012, 6:10 AM
in WalkinGuest form like
public List
??
VulpesPosted Jun 7, 2012, 6:01 AM
Vikas AhlawatPosted Jun 7, 2012, 5:41 AM
VulpesPosted Jun 7, 2012, 5:19 AM
Is it a 'top level' class or is it nested within the DisplayRooms form?
Vikas AhlawatPosted Jun 7, 2012, 5:13 AM
I have already done coding for that and not want to change... because we redirect to WalkinGuest form from may other forms and every for this we need to create every form object... and switch case.. it req. many changes ........... So I don't want to access using DisplayRooms.RoomList
Before this I was using simple list
like List
then there was no error
but when I start using
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; }
}
then error occured.
VulpesPosted Jun 7, 2012, 4:02 AM