473,479 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Adding utility class array to a combo box and Displaying the values to TextBoxes

1 New Member
Hi all I'm having a bit of trouble completeing my coursework basically so far i have created Citenary class with support methods for a private array. The problem is i can add objects to the array through a instance of the class in the main form but im having trouble retreving the data from a combobox. I have the values Name, Passport Number, Issuedby and Expires that are added to the array. The value name is passed to the combobox when a passanger is added but i cant retrive the data from the array for this passanger to display in the textboxes. Ive tryed using selected index changes events but it doesnt seem 2 work. Any help would be much appriciated.

Expand|Select|Wrap|Line Numbers
  1.   [Serializable()]
  2.     public class CItinerary
  3.     {
  4.         private ArrayList arrPassengers; //collection of CPassenger objects
  5.         private ArrayList arrDestinations; //collection of CDestinaton objects
  6.  
  7. #region "Passenger methods"
  8.         public void AddPassenger(CPassenger pIn)
  9.         {
  10.             arrPassengers.Add(pIn);
  11.         }
  12.         public void RemovePassenger(CPassenger pIn)
  13.         {
  14.             arrPassengers.Remove(pIn);
  15.         }
  16.         public void ClearPassanger()
  17.         {
  18.             arrPassengers.Clear();
  19.         }
  20. #region "Class CPassenger"
  21.     public class CPassenger
  22.     {
  23.         private string strName;
  24.         private long lPassportNo;
  25.         private string strIssuer;
  26.         private string strExpires;
  27.  
  28.         public CPassenger()
  29.         {
  30.             strName="Empty";
  31.             lPassportNo=-1;
  32.             strIssuer="Empty";
  33.             strExpires="01.01.1900";
  34.         }
  35.         public CPassenger(string nameIn, long passNoIn, string issuerIn, string expIn)
  36.         {
  37.             strName=nameIn;
  38.             lPassportNo=passNoIn;
  39.             strIssuer=issuerIn;
  40.             strExpires=expIn;
  41.         }
  42.         public string Name
  43.         {
  44.             get{return strName;}
  45.             set{strName = value;}
  46.         }
  47.         public long PassportNumber
  48.         {
  49.             get{return lPassportNo;}
  50.             set{lPassportNo = value;}
  51.         }
  52.         public string IssuedBy
  53.         {
  54.             get{return strIssuer;}
  55.             set{strIssuer = value;}
  56.         }
  57.         public string Expires
  58.         {
  59.             get{return strExpires;}
  60.             set{strExpires = value;}
  61.         }
  62.     }
  63.     #endregion 
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. CItinerary objCurrItinerary; // the current itinerary object
  71.  private string strFileName;
  72. private bool bDirty; //controls save mode and display of cost calculatio
  73. #region "Constructors and Destructors"
  74. public frmPMFMain()
  75. {
  76. InitializeComponent();
  77. objCurrItinerary = new CItinerary(); //empty instance
  78. strFileName = "";
  79. bDirty = false;
  80. int intNumber = 0;
  81.  
  82.  
  83.  
  84.  
  85. ///*** Custom methods and events follow ***///
  86.         #region "Passengers"
  87.         public void AddPassanger()//add new passanger
  88.         {
  89.             CPassenger p = new CPassenger();
  90.             {
  91.                 p.Name = txtName.Text;
  92.                 String pNumber = txtPassport.Text;
  93.                 int intNumber = System.Convert.ToInt32(pNumber);
  94.                 p.PassportNumber = intNumber;
  95.                 p.IssuedBy = txtIssuer.Text;
  96.                 p.Expires = txtExpires.Text;
  97.                 objCurrItinerary.AddPassenger(p);
  98.                 cboPassList.Items.Add(p.Name);
  99.  
  100.                 MessageBox.Show("Passanger " + p.Name + " Has been Added");
  101.                 bDirty= true;   
  102.                 Invalidate();
  103.             }
  104.         }



Thanks matt
Mar 24 '07 #1
0 1131

Sign in to post your reply or Sign up for a free account.

Similar topics

0
464
by: Stephen | last post by:
I have been getting on well with help from this forum trying to create an array list and work with it. Everything is working fine apart from displaying my array list items into the labels in my...
6
565
by: Bhavin | last post by:
Anybody quickly replies it, would be a great help! I try to create dynamic array of textboxes control in ASP.NET(C#). I got the following error while I tried to assign value to ID property of...
1
1807
by: Stephen | last post by:
Was wondering if someone could please help me with an array I'd like to create in an asp.net page. I have to design an array which stores the values of addresses manually entered into textboxes...
5
4641
by: Aaron Ackerman | last post by:
I have a bound combobox the appears on a cell within the column of my bound grid when the user clicks on a cell n(In my vb.net WinForm app). I am trying to allow the adding of an item to that bound...
14
18620
by: Paul_Madden via DotNetMonster.com | last post by:
Basically I have a listbox to which I add simple STRING items- I have a progress bar which I increment whenever I populate another portion of the complete set of items I wish to add. What I observe...
2
2501
by: technocraze | last post by:
Hi community experts, I am encountering a problem to display the corresponding values of the combo box into the textboxes. I have chose option 1 & 3 for this implementation but neither is working....
3
3625
by: sparks | last post by:
I have a combo box that when you go to the next combo box it is filtered based on the value in the previous one. so if combo box 1 has fred as its value then combo box 2 has 1 2 3 for values....
0
1630
by: micksey | last post by:
i have a form linked with access database. code goes like this: <%while not serv.eof %> <tr valign="top"> <td height="30"> <%=serv.fields("serialno") %> </td> <td> <input name="txtSCorCO"...
33
5482
by: buss123 | last post by:
Hi all, combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editable mode, if we select valuese that combo box values r...
0
7027
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7019
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7067
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6719
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6847
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4463
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
555
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.