Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ok how do I get rid of this one lousy error? Severity Code Description Project File Line Suppression State Error CS0111 Type 'Form1' already defines

Ok how do I get rid of this one lousy error?

Severity Code Description Project File Line Suppression State Error CS0111 Type 'Form1' already defines a member called '.ctor' with the same parameter types.

The codes are as followed:

Form1.cs

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;

namespace Week8 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } } }

Form1 designer

namespace Week8 { partial class Form1 { ///

/// Required designer variable. /// private System.ComponentModel.IContainer components = null;

///

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

#region Windows Form Designer generated code

///

/// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.txtLastName = new System.Windows.Forms.TextBox(); this.txtFirstName = new System.Windows.Forms.TextBox(); this.txtIDNumber = new System.Windows.Forms.TextBox(); this.txtClass = new System.Windows.Forms.TextBox(); this.txtGrade = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.textBox6 = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // txtLastName // this.txtLastName.Location = new System.Drawing.Point(77, 38); this.txtLastName.Name = "txtLastName"; this.txtLastName.Size = new System.Drawing.Size(100, 20); this.txtLastName.TabIndex = 0; // // txtFirstName // this.txtFirstName.Location = new System.Drawing.Point(77, 73); this.txtFirstName.Name = "txtFirstName"; this.txtFirstName.Size = new System.Drawing.Size(100, 20); this.txtFirstName.TabIndex = 1; // // txtIDNumber // this.txtIDNumber.Location = new System.Drawing.Point(77, 110); this.txtIDNumber.Name = "txtIDNumber"; this.txtIDNumber.Size = new System.Drawing.Size(100, 20); this.txtIDNumber.TabIndex = 2; // // txtClass // this.txtClass.Location = new System.Drawing.Point(77, 146); this.txtClass.Name = "txtClass"; this.txtClass.Size = new System.Drawing.Size(100, 20); this.txtClass.TabIndex = 3; // // txtGrade // this.txtGrade.Location = new System.Drawing.Point(77, 182); this.txtGrade.Name = "txtGrade"; this.txtGrade.Size = new System.Drawing.Size(100, 20); this.txtGrade.TabIndex = 4; // // button1 // this.button1.Location = new System.Drawing.Point(90, 208); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 5; this.button1.Text = "Add"; this.button1.UseVisualStyleBackColor = true; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(13, 38); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(58, 13); this.label1.TabIndex = 6; this.label1.Text = "Last Name"; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(13, 76); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(57, 13); this.label2.TabIndex = 7; this.label2.Text = "First Name"; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(12, 117); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(58, 13); this.label3.TabIndex = 8; this.label3.Text = "ID Number"; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(13, 153); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(32, 13); this.label4.TabIndex = 9; this.label4.Text = "Class"; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(12, 189); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(36, 13); this.label5.TabIndex = 10; this.label5.Text = "Grade"; // // textBox6 // this.textBox6.Location = new System.Drawing.Point(191, 38); this.textBox6.Multiline = true; this.textBox6.Name = "textBox6"; this.textBox6.ReadOnly = true; this.textBox6.Size = new System.Drawing.Size(175, 164); this.textBox6.TabIndex = 11; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(378, 261); this.Controls.Add(this.textBox6); this.Controls.Add(this.label5); this.Controls.Add(this.label4); this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Controls.Add(this.button1); this.Controls.Add(this.txtGrade); this.Controls.Add(this.txtClass); this.Controls.Add(this.txtIDNumber); this.Controls.Add(this.txtFirstName); this.Controls.Add(this.txtLastName); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); this.PerformLayout();

}

#endregion

private System.Windows.Forms.TextBox txtLastName; private System.Windows.Forms.TextBox txtFirstName; private System.Windows.Forms.TextBox txtIDNumber; private System.Windows.Forms.TextBox txtClass; private System.Windows.Forms.TextBox txtGrade; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; private System.Windows.Forms.TextBox textBox6; } }

Program

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;

namespace Week8 {

//internal class grades : Form //{

//}

public partial class Form1 : Form {

// Get the location where the data file would be created string fileLoc = Application.StartupPath + "\\Datafile.txt"; /* Constructor of the class to create the GUI of the form */ public Form1() { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new grades()); InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { //form the desired string of the text boxes' text string stu_rec = txtLastName.Text + "," + txtFirstName.Text + ":" + txtIDNumber.Text + "" + txtClass.Text + "" + txtGrade.Text; try { //Create an Object of the SteamWriter // class to write the data to the file StreamWriter dat_file = new StreamWriter(fileLoc, true); //Write the data to the file dat_file.WriteLine(stu_rec); //clear the text of all the textbox controls foreach (Control t in this.Controls) { if (t is TextBox) t.Text = ""; } //close the stream dat_file.Close(); } //throw an exception if the exception occurs catch (IOException) { // show the error message MessageBox.Show("Error Occurred. Please try again"); } try { //create a new object of the SteamReader class to read the data from the same file StreamReader read_file = new StreamReader(fileLoc); //variable to read the data string read_rec = ""; //control where the data is to be shown // txtData.Text = ""; //read the data till the end of the file do { //read the data and show it in the text box read_rec = read_file.ReadLine(); // txtData.Text += read_rec + " "; } while (read_rec != null); //close the stream read_file.Close(); } //throw an exception if exception occurs catch (IOException) { //show the message error MessageBox.Show("Problem while reading the file. Please try again."); } }//End class

} // End Namespace }

image text in transcribed

C Chegg St.dyIuile: 5olt x | Quick Lauren (Chi+Q) He Edt View project Buid Uebug leam Iook lest RI005 Analyze window Hel Soution Explorer Fem1 Search Solution lorerCtrl- using Systes.Collections.Ge%ris; Soliton "Wee 11 preyect) uring Syster Drtngs using Syster Text using Syster kincons Fornsj Asp.corrig uing SyatusT hrwading.aka Form1 p.blic partiol class Fored Fore b1ic Ect) 17 ntine Solution 1 Enu. IA 0Wa'"ings l@our1 Mhaaays l%) 0uld + Inteli,mx Co Dsscrition Fie Linc Suppression St. luunEpla ezm Explorer lype Form lresy dehnes CTpthThe types 0 0111member celle: Actve Weeks E O lype here to search

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions