Question WinForm to read and search csv file

shaun.rahman

New member
Joined
Apr 18, 2017
Messages
2
Programming Experience
Beginner
Hi,

Thank you for reading my post! I'm a complete beginner and I need your help to read a static hard coded .csv file, display it's content in a gridview with search functionality.

When the application loads, I want to display as much data as I can on the gridview in alphabetical order and use the search field to search for any data on the csv file.

I have attached the winform design and the csv file. Please note the csv file does not contain all the data.

Please help me as I'm racking my brain out.

Many thanks in advance.
 

Attachments

  • LULPhonebook.zip
    298 bytes · Views: 62
  • WindowsFormsApp1.zip
    23.2 KB · Views: 68
Last edited by a moderator:
Hi,

Thank you for reading my post! I'm a complete beginner and I need your help to read a static hard coded .csv file, display it's content in a gridview with search functionality.

When the application loads, I want to display as much data as I can on the gridview in alphabetical order and use the search field to search for any data on the csv file.

I have attached the winform design and the csv file. Please note the csv file does not contain all the data.

Please help me as I'm racking my brain out.

Many thanks in advance.
Let's take a step back and start with, do you know how to read a csv file in .Net?
 
Hi JuggaloBrotha,

Thanks for your reply. I'm a complete beginner with C sharp. I used to code in C, C++, Modula 2, Cobol etc about 20 years ago.

I don't know how to load a hard coded csv file nor do i know how to search that csv file. Please can you guide me as much as you can if you have the time

Thanks in advance
 
Hi JuggaloBrotha,

Thanks for your reply. I'm a complete beginner with C sharp. I used to code in C, C++, Modula 2, Cobol etc about 20 years ago.

I don't know how to load a hard coded csv file nor do i know how to search that csv file. Please can you guide me as much as you can if you have the time

Thanks in advance
Well for starters reading the file you'll want to become familiar with the System.IO namespace, specifically the System.IO.StreamReader for reading files.
If you want the user to be able to browse the system and select the file to be read, you can use the OpenFileDialog.
As for parsing the CSV file, the rules are really simple for that too.
All of what I mentioned there's tons of examples you can find via very quick Google searches.
 
Hi!

I created a tutorial for you with your given csv. Check it out here:

https://www.csharp-tutorial.hu/csharp/csv-file-reading-and-writing-with-datagridview/
Looking through your tutorial it does actually read/save a csv file however it doesn't seem to handle the full specs of handling a csv file, for example you don't have anything that looks for field qualifying characters (single quote and double quote) for data that contains a comma: Comma-separated values - Wikipedia

Which may not matter to the OP depending on what his data is.
 
Hi! All these you wrote was not mentioned as requirement in your first post. Of course you can extend with many many extra functions this tutorial by request. If you need validation, it can be easily implemented, etc.
 
Back
Top Bottom