This is a brief example of how to set a date time in a Windows Form Application in Visual Studio.
It's for beginners to start learning how to code Windows form applications. I recommend downloading Visual Studio 2015 Community because it's free and compliments learning C#. I also recommend looking for the free courses by Microsoft on their website like how I did. Looking for resources from Youtube videos and other sites are available to help you learn. I just absorbed all the information out there either it be books, websites or videos, they all helped me grasp a foundation for programming. You need a passion for learning, this is a MUST. No matter what DO NOT QUIT LEARNING.
You will succeed if you put in the time and effort. Always have a project in mind and learn from the examples provided on videos or any tutorials out there.
Instructions:
Simply start Microsoft Visual Studio and choose C#-Windows Forms Application.
Select 2 buttons, 1 textbox and 1 label. Drag everything on the form.
Change Label text to Time is:
Change textBox1 to Get time.
Change the second textBox2 to Set time.
Follow the code given to create a time application.
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 First_form
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = DateTime.Now.ToString();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show(textBox1.Text);
}
}
}
No comments:
Post a Comment