Visual Studios Help


Text file named Vendor.txt (vendor#, name, street, city, state, zip, phone):
1,FCC,445 12th Street SW, Washington,DC,20554,888-225-5322
2, U.S, Copyright Office, 101 Independence Ave, Washington, DC,
20559,202-707-3000
3,CDC,1600 Clifton Road,Atlanta,GA,30333,800-323-4636
4,White House, 1600 Pennsylvania Avenue NW,
Washington,DC,20500,202-456-1111
5,Labor Statistics,Postal Sq Bldg,2 Mass
Ave,Washington,DC,20212,800-877-8339
6,AMTRAK,60 Massachusetts Avenue
NE,Washington,DC,20002,800-523-6590
7,U.S. Air Force,1690 Air Force
Pentagon,Washington,DC,20330-1670,800-423-8723
8,National Guard,111 South George Mason
Dr,Arlington,VA,22204,800-864-6264
9,Office of Govt Ethics,1201 New York
Ave,Washington,DC,20005,202-482-9300
10,IRS,1111 Constitution Ave
NW,Washington,DC,20224,800-829-1040
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Here a new Windows Forms Application in C# is created using Visual Studio 2017 with name "VendorsApplication".This application contains a form with name "VendorsDictionary1.cs".Below are the files associated with form1.
1.VendorsDictionary1.cs[Design]

2.VendorsDictionary1.Designer.cs
3.VendorsDictionary1.cs
//namespace
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
//application namespace
namespace VendorsApplication
{
public partial class VendorsDictionary1 : Form
{
public VendorsDictionary1()
{
InitializeComponent();
}
//creating dictionary
Dictionary<string, string> vendorsPhones = new
Dictionary<string, string>();
//form load event
private void VendorList_Load(object sender, EventArgs e)
{
//creating object of StreamReader class
StreamReader streamReader = new StreamReader("Vendor.txt");
//declaring variable to read each line
string line = "";
//declaring array
string[] recordArray = new string[7];
while((line=streamReader.ReadLine())!=null)
{
recordArray = line.Split(',');//split line into array based on
,
//add name as key and phone as value in the dictionary
vendorsPhones.Add(recordArray[1], recordArray[6]);
//add vendor name in the combobox
cmbVendors.Items.Add(recordArray[1]);
}
}
//find button click
private void btnFind_Click(object sender, EventArgs e)
{
//getting selected vendor name from cobobox
string vendorname = cmbVendors.SelectedItem.ToString();
lstVendor.Items.Clear();//clear vendor listbox
foreach (var item in vendorsPhones)
{
//checking item key as vendor name
if(item.Key== vendorname)
{
//if key is found , then add key and value in the listbox
lstVendor.Items.Add(item.Key + " : " + item.Value);
}
}
}
}
}
======================================================
Output : Run application using F5 and will get the screen as shown below
Screen 1 :

Screen 2 :Screen showing vendor names in combobox

Screen 3 :Screen showing vendor name and phone number

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
Visual Studios Help Text file named Vendor.txt (vendor#, name, street, city, state, zip, phone): 1,FCC,445 12th Street SW, Washington,DC,20554,888-225-5322 2, U.S, Copyright Office, 101 Independenc...