none
How to do I get a data from Listview for draw chart? RRS feed

  • Question

  • using System; using System.IO; 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.Collections; using System.Diagnostics; using System.Windows.Forms.DataVisualization.Charting; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public void openFile(TextBox textBox) { } Chart char1 = null; public Form1() { InitializeComponent(); } private Point[] rectGraph = new Point[20]; // Use for Graph Point private int cnt = 0; // Clear this index for use Graph private Pen pen = new Pen(Color.Blue, 5.0f); // Use for Graph Pen // For file open #region Open files //Open File private void toolStripButton1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = "C:\\..\\..\\Desktop"; openFileDialog.Filter = "텍스트파일 (*.txt)|*.txt|데이터파일 (*.dat)|*.dat|모든파일 (*.*)|*.*"; openFileDialog.FilterIndex = 3; openFileDialog.RestoreDirectory = true; // File location saved if (openFileDialog.ShowDialog() == DialogResult.OK) { openfileTextbox.Text = openFileDialog.FileName; //LoadData(openFileDialog.FileName); } } private void fileOpen_2_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = "C:\\..\\..\\Desktop"; openFileDialog.Filter = "Text File (*.txt)|*.txt|Data File (*.dat)|*.dat|All File (*.*)|*.*"; openFileDialog.FilterIndex = 3; openFileDialog.RestoreDirectory = true; // File location saved if (openFileDialog.ShowDialog() == DialogResult.OK) { openfileTextbox.Text = openFileDialog.FileName; //LoadData(openFileDialog.FileName); } } //If push the Load button then will be load the data to listview private void fileLoad_Click(object sender, EventArgs e) { if (openfileTextbox.TextLength > 0) { if (!string.IsNullOrEmpty(openfileTextbox.Text)) LoadData(openfileTextbox.Text); } else if(openfileTextbox.TextLength <= 0) MessageBox.Show("Fail to upload data file."); } private void fileLoad_2_Click_1(object sender, EventArgs e) { if (openfileTextbox.Text.Length > 0) { if (!string.IsNullOrEmpty(openfileTextbox.Text)) LoadData(openfileTextbox.Text); } else if(openfileTextbox.TextLength <= 0) MessageBox.Show("Fail to upload data file."); } // Data Load private void LoadData(string fileName) { using (TextReader tReader = new StreamReader(fileName)) { string[] stringLines = tReader.ReadToEnd().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (string stringLine in stringLines) { if (stringLine != string.Empty) { //Divide this unit to use separator string[] stringArray = stringLine.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); //Composition items ListViewItem item = listView1.Items.Add(stringArray[0]); item.SubItems.Add(stringArray[1]); } } } } private void Dataset(string dataSet) { } #endregion // For Drawing Graph chart #region Drawing Graphfield. private void button1_Click(object sender, EventArgs e) { //DataTable splinechart = new DataTable(); //chart1.Series = ; } #endregion // For Program's other utility #region ect. Program use // Developer info form load private void info_Developer_Click(object sender, EventArgs e) { Form2 Developer = new Form2(); Developer.Show(); } // Program exit private void Exit_Click(object sender, EventArgs e) { Application.Exit(); } // Listview Clear private void toolStripButton2_Click(object sender, EventArgs e) { listView1.Items.Clear(); } //opening file in notepad private void ContectEdit_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start(@"C:\windows\system32\notepad.exe", openfileTextbox.Text); } #endregion } }

    I want input data(from listview) to MS chart. but I don't know how to do.

    plz someone help me.


    Wednesday, July 18, 2012 5:15 AM

Answers