473,382 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

using the ListBox class and File I/O

Hi

I am a relatively inexperienced and I need help in this, what seems to
be a simple task
I am trying to read from a text file which contains a list of peoples
names in the format 'Surname Firstname' e.g 'Mo Greene'
each line in the textfile is a name. I want to select a name, I was
thinking of using a ListBox, so I need to know how to read each line
and populate the ListBox where each entry in the listbox is 1 line in
the textfile. When a particular entry is selected in the listbox I want
to take that entry and split the Firstname and Surname and return them
in a TextBox or any other suitable component. I also need to return
information in a suitable component/window pertaining to that
particular person, for example, I select Mo Green and when I hit go it
will return Mo Greene's personal information, I do not know where I
should return this (i.e what component I hsould use to display the
information)
I would appreciate any sort of help!!!! Thanks!!

Nov 16 '05 #1
2 2396
Hi Light,

Take a look at StreamReader.ReadLine(), and the ListBox's SelectedIndexChanged event.
That should get you started. Feel free to ask again when you get stuck.

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
Hi,

Where is the info of these persons?
The file you said only contains the name, nothing else.

this is a pseudo code ( I did not test it ) to read the file and populate
the listbox

StreamReader reader = new StreamReader( file)
string line;
while( ( line=reader.ReadLine)!= null )
theListBox.Items.Add( line);
reader.Close();

hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Light" <ay********@gmail.com> wrote in message
news:ch********@odah37.prod.google.com...
Hi

I am a relatively inexperienced and I need help in this, what seems to
be a simple task
I am trying to read from a text file which contains a list of peoples
names in the format 'Surname Firstname' e.g 'Mo Greene'
each line in the textfile is a name. I want to select a name, I was
thinking of using a ListBox, so I need to know how to read each line
and populate the ListBox where each entry in the listbox is 1 line in
the textfile. When a particular entry is selected in the listbox I want
to take that entry and split the Firstname and Surname and return them
in a TextBox or any other suitable component. I also need to return
information in a suitable component/window pertaining to that
particular person, for example, I select Mo Green and when I hit go it
will return Mo Greene's personal information, I do not know where I
should return this (i.e what component I hsould use to display the
information)
I would appreciate any sort of help!!!! Thanks!!

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vengeance | last post by:
On the parent_form.aspx I have these controls <asp:listbox id="Operators" runat="server" Width="163px" SelectionMode="Multiple" Rows="2"></asp:listbox> <INPUT class="loButton" onclick="java...
4
by: Bernie Yaeger | last post by:
I now know how to gather the file type icons and I'm able to use them in a listview. But a listbox does not have a .smallimagelist or .largeimagelist member, so I don't know how to translate that...
7
by: diffuser78 | last post by:
I recently tried a hand at wxGlade and was happy to see it designs a GUI for you in minutes. I am a newbie Python coder. I am not completely aware of GUI programming. I can easily make menubars...
2
by: rn5a | last post by:
Using the FileSystemInfo class, I am retrieving all the directories & files existing in a particular directory on the server & listing them in a ListBox. If an item in the ListBox happens to be a...
2
by: rrflore2 | last post by:
Ok. I'm writing and deleting to an xml file using a dataset. I have a function in my codebehind page that binds a listbox to the dataset that performs the writes/deletes. Everything seems to be...
2
by: =?Utf-8?B?Sm9zaFA=?= | last post by:
I have a single form C# application called MainUI. On MainUI I have a listbox that will log certain activity occuring in a seperate class file. For example, the Class has a function that loops...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
5
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that...
1
by: jasydnor | last post by:
Hi, New to the forums and have a question. I've only been developing for about five months now so I apologize if this seems oversimplistic....I am writing a program on an idea I had on a whim. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.