A
anonymous_3210
Guest
Hello there,
I'm stuck with loading CSV file.
I want to get the first column of the CSV in the checkedlistbox after i hit the OK button(button3) once i browse or enter file location.
Here is the screenshot and my code
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;
namespace demover2_copy
{
public partial class Form1 : Form
{
private string strfilename;
public Form1()
{
InitializeComponent();
button3.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
button3.Enabled = false;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = ("comma seperated value | *.CSV");
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string strfilename = openFileDialog1.FileName;
if (File.Exists(strfilename))
{
textBox1.Text = strfilename;
}
else
{
strfilename = "";
}
if (!string.IsNullOrWhiteSpace(strfilename))
{
textBox1.Text = strfilename;
}
else
{
MessageBox.Show("Please select a file");
}
}
else
{
MessageBox.Show("Please select a file");
}
}
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text == "")
button3.Enabled = false;
else
button3.Enabled = true;
}
private void button3_Click(object sender, EventArgs e)
{
filecheck();
}
private void filecheck()
{
string strfilename = textBox1.Text;
if (File.Exists(strfilename))
{
textBox1.Text = strfilename;
}
else
{
strfilename = "";
}
if (!string.IsNullOrWhiteSpace(strfilename))
{
textBox1.Text = strfilename;
}
else
{
MessageBox.Show("Please select a valid file");
}
}
}
}
Akshay
Continue reading...
I'm stuck with loading CSV file.
I want to get the first column of the CSV in the checkedlistbox after i hit the OK button(button3) once i browse or enter file location.
Here is the screenshot and my code
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;
namespace demover2_copy
{
public partial class Form1 : Form
{
private string strfilename;
public Form1()
{
InitializeComponent();
button3.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
button3.Enabled = false;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = ("comma seperated value | *.CSV");
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string strfilename = openFileDialog1.FileName;
if (File.Exists(strfilename))
{
textBox1.Text = strfilename;
}
else
{
strfilename = "";
}
if (!string.IsNullOrWhiteSpace(strfilename))
{
textBox1.Text = strfilename;
}
else
{
MessageBox.Show("Please select a file");
}
}
else
{
MessageBox.Show("Please select a file");
}
}
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text == "")
button3.Enabled = false;
else
button3.Enabled = true;
}
private void button3_Click(object sender, EventArgs e)
{
filecheck();
}
private void filecheck()
{
string strfilename = textBox1.Text;
if (File.Exists(strfilename))
{
textBox1.Text = strfilename;
}
else
{
strfilename = "";
}
if (!string.IsNullOrWhiteSpace(strfilename))
{
textBox1.Text = strfilename;
}
else
{
MessageBox.Show("Please select a valid file");
}
}
}
}
Akshay
Continue reading...