Skip to content

Instantly share code, notes, and snippets.

@nelopauselli
Created July 13, 2012 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelopauselli/3104158 to your computer and use it in GitHub Desktop.
Save nelopauselli/3104158 to your computer and use it in GitHub Desktop.
Clase responsable del manejo del formulario
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnBrowse_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "XML Document (*.xml)|*.xml|All Files (*.*)|*.*";
var result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK) {
txtFileName.Text = openFileDialog1.FileName;
btnLoad.Enabled = true;
}
}
private void btnLoad_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
var fileName = txtFileName.Text;
var reader = new MyFileReader();
reader.ReadFile(fileName, AddItemToListView);
}
private void AddItemToListView(string id, string name, string unitPrice, string discontinued)
{
var item = new ListViewItem(new string[] { id, name, unitPrice, discontinued });
listView1.Items.Add(item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment