- by JB
So my program works like this: using winforms, user enters ID number, using an array, based on the right id number, that student information and class schedule outputs in a message box!
My question is how to take the 4 classes in the message box/array and write them to the linklabel text in form 2????
My Getschedule class contains the array and is listed below:
namespace Eagle_Eye_Class_Finder
{
public class GetSchedule
{
IDnumber[] IDnumbers = new IDnumber[3];
public string GetDataFromNumber(string ID)
{
foreach (IDnumber IDCandidateMatch in IDnumbers)
{
if (IDCandidateMatch.ID == ID)
{
StringBuilder myData = new StringBuilder();
myData.AppendLine(IDCandidateMatch.Name);
myData.AppendLine(": ");
myData.AppendLine(IDCandidateMatch.ID);
myData.AppendLine(IDCandidateMatch.year);
myData.AppendLine(IDCandidateMatch.class1);
myData.AppendLine(IDCandidateMatch.class2);
myData.AppendLine(IDCandidateMatch.class3);
myData.AppendLine(IDCandidateMatch.class4);
//return myData;
return myData.ToString();
}
}
return "";
}
public GetSchedule()
{
IDnumbers[0] = new IDnumber() { Name = "Joshua Banks", ID = "900456317", year = "Senior", class1 = "TEET 4090", class2 = "TEET 3020", class3 = "TEET 3090", class4 = "TEET 4290" };
IDnumbers[1] = new IDnumber() { Name = "Sean Ward", ID = "900456318", year = "Junior", class1 = "ENGNR 4090", class2 = "ENGNR 3020", class3 = "ENGNR 3090", class4 = "ENGNR 4290" };
IDnumbers[2] = new IDnumber() { Name = "Terrell Johnson", ID = "900456319", year = "Sophomore", class1 = "BUS 4090", class2 = "BUS 3020", class3 = "BUS 3090", class4 = "BUS 4290" };
}
public class IDnumber
{
public string Name { get; set; }
public string ID { get; set; }
public string year { get; set; }
public string class1 { get; set; }
public string class2 { get; set; }
public string class3 { get; set; }
public string class4 { get; set; }
public static void ProcessNumber(IDnumber myNum)
{
StringBuilder myData = new StringBuilder();
myData.AppendLine(myNum.Name);
myData.AppendLine(": ");
myData.AppendLine(myNum.ID);
myData.AppendLine(myNum.year);
myData.AppendLine(myNum.class1);
myData.AppendLine(myNum.class2);
myData.AppendLine(myNum.class3);
myData.AppendLine(myNum.class4);
MessageBox.Show(myData.ToString());
}
}
}
}
My form 2 which will contain the linklabels is listed below:
public class YOURCLASSSCHEDULE : System.Windows.Forms.Form
{
public System.Windows.Forms.LinkLabel linkLabel1;
public System.Windows.Forms.LinkLabel linkLabel2;
public System.Windows.Forms.LinkLabel linkLabel3;
public System.Windows.Forms.LinkLabel linkLabel4;
private Button button1;
/// Required designer variable.
public System.ComponentModel.Container components = null;
public YOURCLASSSCHEDULE()
{
//
InitializeComponent();
// TODO: Add any constructor code after InitializeComponent call
}
/// Clean up any resources being used.
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (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.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(YOURCLASSSCHEDULE));
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.linkLabel2 = new System.Windows.Forms.LinkLabel();
this.linkLabel3 = new System.Windows.Forms.LinkLabel();
this.linkLabel4 = new System.Windows.Forms.LinkLabel();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// linkLabel1
//
this.linkLabel1.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.linkLabel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.linkLabel1.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.linkLabel1.LinkArea = new System.Windows.Forms.LinkArea(0, 7);
this.linkLabel1.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
this.linkLabel1.Location = new System.Drawing.Point(41, 123);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(288, 32);
this.linkLabel1.TabIndex = 1;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "Class 1";
this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// linkLabel2
//
this.linkLabel2.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.linkLabel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.linkLabel2.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.linkLabel2.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
this.linkLabel2.Location = new System.Drawing.Point(467, 123);
this.linkLabel2.Name = "linkLabel2";
this.linkLabel2.Size = new System.Drawing.Size(288, 32);
this.linkLabel2.TabIndex = 2;
this.linkLabel2.TabStop = true;
this.linkLabel2.Text = "Class 2";
this.linkLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.linkLabel2.VisitedLinkColor = System.Drawing.Color.Navy;
this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked);
//
// linkLabel3
//
this.linkLabel3.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.linkLabel3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.linkLabel3.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.linkLabel3.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
this.linkLabel3.Location = new System.Drawing.Point(41, 311);
this.linkLabel3.Name = "linkLabel3";
this.linkLabel3.Size = new System.Drawing.Size(288, 32);
this.linkLabel3.TabIndex = 3;
this.linkLabel3.TabStop = true;
this.linkLabel3.Text = "Class 3";
this.linkLabel3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.linkLabel3.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel3_LinkClicked);
//
// linkLabel4
//
this.linkLabel4.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.linkLabel4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.linkLabel4.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.linkLabel4.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
this.linkLabel4.Location = new System.Drawing.Point(467, 311);
this.linkLabel4.Name = "linkLabel4";
this.linkLabel4.Size = new System.Drawing.Size(288, 32);
this.linkLabel4.TabIndex = 4;
this.linkLabel4.TabStop = true;
this.linkLabel4.Text = "Class 4";
this.linkLabel4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.linkLabel4.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel4_LinkClicked);
//
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ClientSize = new System.Drawing.Size(790, 482);
this.Controls.Add(this.button1);
this.Controls.Add(this.linkLabel4);
this.Controls.Add(this.linkLabel3);
this.Controls.Add(this.linkLabel2);
this.Controls.Add(this.linkLabel1);
this.Font = new System.Drawing.Font("OldDreadfulNo7 BT", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "YOURCLASSSCHEDULE";
this.Text = "Your Classes";
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false);
}
#endregion
public void Form2_Load(object sender, System.EventArgs e)
{
// if (text == "900456317")
// {
//}
}
public void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://www.georgiasouthern.edu/map/");
}
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
}
private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
}
private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Form1 form1 = new Form1();
form1.Show();
this.Hide();
}
}
}