В одном файле (и Combo) названия сайтов, в другом - ссылки. Как задать соответствие - C#
Формулировка задачи:
Есть проект
На форме находится 2 текст бокса, 2 кнопки и 1 комбо бокс
сохраняется 2 файла, в одном ссылки в другом названия сайтов
в комбо боксе отображаются только названия
Теперь сам вопрос, как сделать так, что бы при выборе названия из комбо бокса открывалась нужная ссылка ?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace Link
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string[] str;
string[] str1;
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
try
{
str = File.ReadAllLines("BaseName.txt");
str1 = File.ReadAllLines("BaseLink.txt");
comboBox1.Items.AddRange(File.ReadAllLines("BaseName.bob"));
}
catch (Exception)
{ }
}
private void button1_Click(object sender, EventArgs e)
{
comboBox1.Items.Add(textBox2.Text);
StreamWriter sw = new StreamWriter("BaseName.txt", true);
sw.WriteLine(textBox1.Text);
sw.Close();
StreamWriter sww = new StreamWriter("BaseLink.txt", true);
sww.WriteLine(textBox1.Text);
sww.Close();
}
private void button2_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start();
}
}
}Решение задачи: «В одном файле (и Combo) названия сайтов, в другом - ссылки. Как задать соответствие»
textual
Листинг программы
struct Hyperlink
{
public string Name { get; set; }
public string Url { get; set; }
public override string ToString()
{
return Name;
}
}