dimanche 1 mars 2015

How to pass an object between forms with winforms using c#?

I am trying to pass object from one from to another.


so here is what I have done.


from form 1



if (i._itemType == "Phone Activation") {

using (TrackInfoPhoneActivation form2 = new TrackInfoPhoneActivation()) {
if (form2.ShowDialog() == DialogResult.OK) {
AdditionalInfoPhoneActivations obj = form2.AdditionalInfoPhoneActivationsObject();
}
}

}


and from on the TrackInfoPhoneActivation form, I have this



public AdditionalInfoPhoneActivations AdditionalInfoPhoneActivationsObject() {
var t = new AdditionalInfoPhoneActivations();
t.phoneNumber = InputPhoneNumber.Text;
t.serialNumber = InputSerialNumber.Text;
t.saleType = InputSaleType.SelectedValue.ToString();
t.carrierID = (int)InputCarrier.SelectedValue;
return t;

}


but I keep getting this error



Error 1 Inconsistent accessibility: return type 'RM.AdditionalInfoPhoneActivations' is less accessible than method 'RM.TrackInfoPhoneActivation.AdditionalInfoPhoneActivationsObject()' C:\Users\User\C# Projects\RM\RM\TrackInfoPhoneActivation.cs 23 47 RM


What am I doing wrong here? and how can I correctly pass this object from AdditionalInfoPhoneActivations to form1?


Aucun commentaire:

Enregistrer un commentaire