Question

Hey there, I am having a hard time using GUI for c# in visual studio. I...

Hey there, I am having a hard time using GUI for c# in visual studio. I am making an alarm clock. I have a few questions that I would like to know how to do:

--using a button called set time to capture text from a box containing a user-inputted hour, minute, second, and setting the current time to that.

--using a button called alarm, Capture the Text in the TextBoxes - the Hours, Minutes, Seconds and Text (am/pm) and create a new AlarmTime object with those for values for Hours, Minutes, Seconds and Message (am / pm) and enter the time of the alarm in the ListBox (the ListBox should always be sorted).

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

Output will be like

Form Hour 23 Hour 9 Minute 59 Minute 33 Second 3 Second 44 Text am/pm pm set time Alaram 9,33.44.pm 10,33,44,am 12,33.44,am 23,33.44.am

Note: The alarm time listed is auto sorted using the hour alone

Code will be like

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace AlaramTimeForms
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
List<Alaram> list = new List<Alaram>();

private void button1_Click(object sender, EventArgs e)
{
currentTime obj = new currentTime();
obj.hour = textBox1.Text;
obj.minute = textBox2.Text;
obj.second = textBox3.Text;

}

private void button3_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
Alaram obj = new Alaram();
obj.hour = Convert.ToInt16(textBox6.Text);
obj.minute = textBox5.Text;
obj.second = textBox4.Text;
obj.text = textBox7.Text;

list.Add(obj);
List<Alaram> SortedList = list.OrderBy(o => o.hour).ToList();

for (int i = 0; i < list.Count; i++)
{
listBox1.Items.Add(SortedList[i].hour + "," + SortedList[i].minute + "," + SortedList[i].second + "," + SortedList[i].text);

}

  
  
  
}
}


class currentTime
{
public string hour;
public string minute;
public string second;
}

class Alaram
{
public int hour;
public string minute;
public string second;
public string text;
}
}

Designer code will be like:

namespace AlaramTimeForms
{
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()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.textBox5 = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.textBox6 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.textBox7 = new System.Windows.Forms.TextBox();
this.button3 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(58, 35);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 0;
//
// 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(30, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Hour";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(13, 85);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(39, 13);
this.label2.TabIndex = 3;
this.label2.Text = "Minute";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(58, 82);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 2;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(13, 128);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(44, 13);
this.label3.TabIndex = 5;
this.label3.Text = "Second";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(63, 125);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(100, 20);
this.textBox3.TabIndex = 4;
//
// button1
//
this.button1.Location = new System.Drawing.Point(42, 190);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 6;
this.button1.Text = "set time";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(271, 128);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(44, 13);
this.label4.TabIndex = 12;
this.label4.Text = "Second";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(321, 125);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(100, 20);
this.textBox4.TabIndex = 11;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(271, 85);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(39, 13);
this.label5.TabIndex = 10;
this.label5.Text = "Minute";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(316, 82);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(100, 20);
this.textBox5.TabIndex = 9;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(271, 38);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(30, 13);
this.label6.TabIndex = 8;
this.label6.Text = "Hour";
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(316, 35);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(100, 20);
this.textBox6.TabIndex = 7;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(246, 174);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(64, 13);
this.label7.TabIndex = 14;
this.label7.Text = "Text am/pm";
//
// textBox7
//
this.textBox7.Location = new System.Drawing.Point(321, 174);
this.textBox7.Name = "textBox7";
this.textBox7.Size = new System.Drawing.Size(100, 20);
this.textBox7.TabIndex = 13;
//
// button3
//
this.button3.Location = new System.Drawing.Point(321, 229);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 16;
this.button3.Text = "Alaram";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(181, 312);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(120, 95);
this.listBox1.TabIndex = 17;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(517, 449);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button3);
this.Controls.Add(this.label7);
this.Controls.Add(this.textBox7);
this.Controls.Add(this.label4);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.label5);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.label6);
this.Controls.Add(this.textBox6);
this.Controls.Add(this.button1);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox textBox6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox textBox7;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.ListBox listBox1;
}
}

Please rate it if the above solution helps you in any way or if you have any concerns comment it, I will help you through again.

Add a comment
Know the answer?
Add Answer to:
Hey there, I am having a hard time using GUI for c# in visual studio. I...
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
  • This is a C++ Program I created in Visual Studio for class. The problem I am...

    This is a C++ Program I created in Visual Studio for class. The problem I am having is I get an error msg that says, "no matching token found for line 8." What am I missing? I see an opening bracket and a closing bracket. But, the program will not build because it says more or less the bracket is missing. FYI....Line 8, is the bracket directly under int main (). Can someone help me understand where I am going...

  • Can you write the code for this It's for Visual Basic I am having a hard...

    Can you write the code for this It's for Visual Basic I am having a hard time getting it to work Telling me error Thank u I will rate a good so other students can learn from this

  • (Mobile-Android Studio) Hello. Thank you for coming to help me:) I am using the Andriod studio...

    (Mobile-Android Studio) Hello. Thank you for coming to help me:) I am using the Andriod studio on mac. and using Java code to develop. and Please start with basic activity with constraints layout (not empty). (audio file is not given, let's say there any audio file). I just would like to see the codes how it works. Thank you very much. I would like to know how to write a program that includes two buttons called plays Play and Stop....

  • I am having a hard time with my program to assignment 4.12. Here are the instructions:...

    I am having a hard time with my program to assignment 4.12. Here are the instructions: The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: <last name> <hours worked> <hourly wage> Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report...

  • Using Visual Studio 2015, how would I code the following Uodate button event handler in c#?...

    Using Visual Studio 2015, how would I code the following Uodate button event handler in c#? then displayed in the student list box. Create an interface as follows The initial form for the application should appear as follows Student Scores Students dd New. Lpdate Delete Ext To update, delete or add student information create the following form Enter Student Information Name Student ID MdtemRna Cancel Note: the Control Box property is set to false

  • Hey, i was just wondering how i would calculate over time pay in c++ visual studio...

    Hey, i was just wondering how i would calculate over time pay in c++ visual studio 2017? what i have right now is either returning 0 for some reason or being skipped over? im also wondering about the federal tax as well because that also doesn't seem to work, any help is greatly appreciated! these are my variables char chChoice = ' '; int intempID = 0; int intHours = 0; int intOThours = 0; float flOTrate = 0; float...

  • PLEASE HELP WITH THESE TWO, I AM HAVING HARD TIME WITH MATERIAL IM TRYING TO ESTABLISH...

    PLEASE HELP WITH THESE TWO, I AM HAVING HARD TIME WITH MATERIAL IM TRYING TO ESTABLISH A PATTERN OR CONSISTENCY .THANK YOU Implement Y-A+C B+D) using CMOS circuit Implement Y Y-A-B-C+A-B-C using CMOS circuit

  • Please Exaplain with calculations. I am having a very hard time with this problem! II: Magnetic...

    Please Exaplain with calculations. I am having a very hard time with this problem! II: Magnetic field Due in 7 hours, 48 y1 Two wires carry current 11-49 A and 12-25 A in the opposite directions parallel to the x-axis at y1·4 cm and y2-15 cm, where on the y-axis (in cm) is the magnetic field zero?

  • A fitness tracking app company has asked you to develop a windows application using a GUI...

    A fitness tracking app company has asked you to develop a windows application using a GUI to determine the total amount of hours somebody has exercised during their lifetime, assuming on average a user has exercises 2.5 hours per week. When the user uses the app, they will enter the following: First Name: Last Name: Date of Birth (in mm/dd/yyyy): Current Date (in mm/dd/yyyy) This program should display the users name and the number of hours the user has exercised...

  • If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but...

    If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but minor discrepancies may require you to adjust. If you are attempting this assignment using another version of Visual Studio, you can expect differences in the look, feel, and/or step-by-step instructions below and you’ll have to determine the equivalent actions or operations for your version on your own. INTRODUCTION: In this assignment, you will develop some of the logic for, and then work with, the...

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