Created
July 13, 2012 10:36
-
-
Save nelopauselli/3104158 to your computer and use it in GitHub Desktop.
Clase responsable del manejo del formulario
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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