日期:2014-05-18 浏览次数:21099 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace CsvToDB
{
public partial class CsvDataForm : Form
{
public CsvDataForm()
{
InitializeComponent();
}
private void btnBrowse_Click(object sender, EventArgs e)
{
openFileDialog1.FilterIndex = 0;
openFileDialog1.FileName = "";
openFileDialog1.Filter = "csv files (*.csv)|*.csv|All files (*.*)|*.*";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
foreach (string s in openFileDialog1.FileNames)
{
listBox1.Items.Add(s);
}
}
}
private void button1_Click(object sender, EventArgs e)
{
string strText;
string strValue;
for (int i = 0; i < listBox1.Items.Count; i++)
{
strText = listBox1.Items[i].text;
strValue = listBox1.Items[i].value;
}
}
}
}
foreah(dataitems di in listbox1.items)
{
strText=di.tostring();
}