Question

You must let the user select a data file (using common dialog control) to read. After...

You must let the user select a data file (using common dialog control) to read.

After reading the file, draw a graph of some kind to represent the data.

C# Form Application

what kind of coding should I use to achieve this?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have developed a sample form applciaton that consists of open file dialog box and chart control.

After reading the data using the file upload.

We can pass it to the series value in the chart.

Please refer below.

Form:

Designer:

namespace DataReadAndGraph
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.button1 = new System.Windows.Forms.Button();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.SuspendLayout();
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(185, 48);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(104, 48);
this.button1.TabIndex = 0;
this.button1.Text = "Read File";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// chart1
//
chartArea1.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea1);
legend1.Name = "Legend1";
this.chart1.Legends.Add(legend1);
this.chart1.Location = new System.Drawing.Point(111, 178);
this.chart1.Name = "chart1";
series1.ChartArea = "ChartArea1";
series1.Legend = "Legend1";
series1.Name = "Series1";
this.chart1.Series.Add(series1);
this.chart1.Size = new System.Drawing.Size(300, 300);
this.chart1.TabIndex = 1;
this.chart1.Text = "chart1";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(595, 511);
this.Controls.Add(this.chart1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
}
}

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 DataReadAndGraph
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();

string path = openFileDialog1.FileName;

using (StreamReader reader = new StreamReader(path))
{
while (true)
{
string line = reader.ReadLine();
  
  
}
}
}
}
}

Add a comment
Know the answer?
Add Answer to:
You must let the user select a data file (using common dialog control) to read. After...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Random Number File Reader This exercise assumes you have completed Programming Problem 13, Random Number File...

    Random Number File Reader This exercise assumes you have completed Programming Problem 13, Random Number File Writer . Create another application that uses an OpenFileDialog control to let the user select the file that was created by the application that you wrote for Problem 13. This application should read the numbers from the file, display the numbers in a ListBox control, and then display the following data: • The total of the numbers • The number of random numbers read...

  • The name of the C++ file must be search.cpp Write a program that will read data...

    The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...

  • Project 4: Month-end Sales Report with array and validation Input dialog box for initial user prompt...

    Project 4: Month-end Sales Report with array and validation Input dialog box for initial user prompt with good data and after invalid data Input OK Cancel Input dialog boxes with sample input for Property 1 Ingut X Input Enter the address for Property 1 Enter the value of Property 1: OK Cancel Input dialog boxes after invalid data entered for Property 1 Error Please enter anmumber greater than D Ester the walue of Peoperty t Console output END SALES REPORT...

  • Using C programming For this project, you have been tasked to read a text file with student grade...

    Using C programming For this project, you have been tasked to read a text file with student grades and perform several operations with them. First, you must read the file, loading the student records. Each record (line) contains the student’s identification number and then four of the student’s numerical test grades. Your application should find the average of the four grades and insert them into the same array as the id number and four grades. I suggest using a 5th...

  • Creating Graphs First, write Java code in GraphTest.java to read a data file (graph.in) and create...

    Creating Graphs First, write Java code in GraphTest.java to read a data file (graph.in) and create a graph using the input data. The input file must have the following format: 6 049 0 27 2 3 1 25 2 1 5 6 352 4 5 1 Here, the number on the first line represents the number of vertices in the graph. The letter on the second line indicates whether this is a directed graph ('D') or an undirected graph ('U')....

  • You are to write a basic fitness application, in C++, that allows the user of the...

    You are to write a basic fitness application, in C++, that allows the user of the application to manually edit “diet” and “exercise” plans. For this application you will need to create three classes: DietPlan, ExercisePlan, and FitnessAppWrapper. Diet Plan Attributes: The class DietPlan is used to represent a daily diet plan. Your class must include three data members to represent your goal calories (an integer), plan name (a std::string), and date for which the plan is intended (a std::string)....

  • Function / File Read (USING MATLAB) A) create a user-defined function : [maxsample , maxvalue , numsamples]=writetofile(sname,strgth) to do the following: The user-defined function shall: -Accept as t...

    Function / File Read (USING MATLAB) A) create a user-defined function : [maxsample , maxvalue , numsamples]=writetofile(sname,strgth) to do the following: The user-defined function shall: -Accept as the input a provided string for the sample name (sname) and number for strength (strgth) - open a text file named mytensiledata.txt, with permission to read or append the file. - Make sure to capture any error in opening the file - Write sname and strgth to the file - Close the file...

  • Write a Java program to read customer details from an input text file corresponding to problem...

    Write a Java program to read customer details from an input text file corresponding to problem under PA07/Q1, Movie Ticketing System The input text file i.e. customers.txt has customer details in the following format: A sample data line is provided below. “John Doe”, 1234, “Movie 1”, 12.99, 1.99, 2.15, 13.99 Customer Name Member ID Movie Name Ticket Cost Total Discount Sales Tax Net Movie Ticket Cost Note: if a customer is non-member, then the corresponding memberID field is empty in...

  • Write a program that reverses a text file by using a stack. The user interface must...

    Write a program that reverses a text file by using a stack. The user interface must consist of 2 list boxes and 3 buttons. The 3 buttons are: Read - reads the text file into list box 1. Reverse - reverses the items in list box 1 by pushing them onto stack 1, then popping them from stack 1 (in the reverse order) and adding them to list box 2. Write - writes the contents of list box 2 to...

  • Write a C++ menu driven Payroll program. Must be user friendly.   Menu 1. Check data file  ...

    Write a C++ menu driven Payroll program. Must be user friendly.   Menu 1. Check data file   2. Read Data file 3. Process payroll for one employee 4. Process payroll for all employees 5. Print out to a text or an HTML file 6. Exit You must use the following Payroll classes, structures, pointers, arrays, enum, vector, recursive, advance file I/O, STL, iterators and containers. The program to process an input file below to calculate tax of 28% and output it...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT