Can someone please give me some advise on the following.
I am currently doing a project where I have to store students records and I have to retrieve
these records. This has to be done by using windows forms with C#. My idea is, is to use a
collection array list to store the records. In the form I want to add code for a button
click event that displays the records within the textboxes of the form when a record is
retrieved from the collection array List. The problem that I have however, is how to
convert the entered string to be displayed in the text box. For example, if the entered
string is 'science' and stored in the collection array list called RegList. When I try to
display this string in the text box, the fully qualified name is displayed, i.e
System.Windows.Forms.TextBox, Text: science.
I just want the entered string to be displayed.
This is the conversion code that I use to display the code in the textbox:
txtFirstnm.Text = RegList[1].ToString();
'txtFirstnm' is the name of the text box and 'RegList' is the collection array list.
I hope someone can assist with this it would be of great help. Thanks
Stan GershengorenPosted Apr 23, 2006, 9:34 PM
My guess is that you are storing the entire textbox in your arraylist and you should not do that.
You are doing something like this:
RegList.Add (txtFirstnm)
and you probably should do this
RegList.Add (txtFirstnm.Text)
But in case you HAVE to do this, here's how you can get what you need:
txtFirstnm.Text = ((TextBox)RegList[1]).Text;
Hope this helps.