0% found this document useful (0 votes)
22 views

C#

The document describes a Windows forms application with two forms. The first form contains rectangles that are drawn and filled with different colors. It also moves when arrow keys are pressed and opens the second form after 5 seconds when a button is clicked. The second form contains text boxes and buttons but does not provide details on their functionality.

Uploaded by

Vasile Vrabie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

C#

The document describes a Windows forms application with two forms. The first form contains rectangles that are drawn and filled with different colors. It also moves when arrow keys are pressed and opens the second form after 5 seconds when a button is clicked. The second form contains text boxes and buttons but does not provide details on their functionality.

Uploaded by

Vasile Vrabie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

namespace WindowsFormsApp12

{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.StartPosition = FormStartPosition.CenterScreen;

Button b = new Button();


b.Location = new Point(15, 118);
b.Name = "Button";
b.Text = "Pornește";
b.Size = new Size(100, 50);
b.Font = new Font("Minion Pro", 9);
b.Padding = new Padding(0);
b.Click += new EventHandler(this.Button_Click);

this.Controls.Add(b);

}
Pen Yellow = new Pen(Color.Yellow);
Pen Blue = new Pen(Color.Blue);
Pen Red = new Pen(Color.Red);
System.Drawing.SolidBrush FillYellow = new System.Drawing.SolidBrush(Color.Yellow);
System.Drawing.SolidBrush FillBlue = new System.Drawing.SolidBrush(Color.Blue);
System.Drawing.SolidBrush FillRed = new System.Drawing.SolidBrush(Color.Red);

Rectangle rect1 = new Rectangle(20,20,75,90);


Rectangle rect2 = new Rectangle(90, 20, 75, 90);
Rectangle rect3 = new Rectangle(165, 20, 75, 90);

private void Form1_Paint(object sender, PaintEventArgs e)


{
Graphics g = e.Graphics;

g.DrawRectangle(Yellow, rect1);
g.DrawRectangle(Blue, rect2);
g.DrawRectangle(Red, rect3);

g.FillRectangle(FillYellow, rect1);
g.FillRectangle(FillBlue, rect2);
g.FillRectangle(FillRed, rect3);
}

private void Form1_Load(object sender, EventArgs e)


{

private void Form1_KeyDown(object sender, KeyEventArgs e)


{
if (e.KeyCode == Keys.Down)
{
this.Top += 50;
}

if (e.KeyCode == Keys.Up)
{
this.Top -= 50;
}

private void button1_Click(object sender, EventArgs e)


{

private void timer1_Tick(object sender, EventArgs e)


{
MessageBox.Show("Timp trecut!");
Form2 form = new Form2();
form.Show();
Visible = false;
timer1.Stop();

private void Button_Click(object sender, EventArgs e)


{
timer1.Interval = 5000;
timer1.Start();
}

}
}
Form2---------------------------------------------------------------------------------------------
using System.Data.SqlClient;

namespace WindowsFormsApp12
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
Button b = new Button();
b.Location = new Point(15, 110);
b.Name = "Button1";
b.Text = "Salvează";
b.Size = new Size(70, 30);
b.Font = new Font("Minion Pro", 9);
b.Padding = new Padding(0);
b.Click += new EventHandler(this.Button_click);
this.Controls.Add(b);

Button c = new Button();


c.Location = new Point(15, 150);
c.Name = "Button2";
c.Text = "Bursa";
c.Size = new Size(70, 30);
c.Font = new Font("Minion Pro", 9);
c.Padding = new Padding(0);
c.Click += new EventHandler(this.Button2_click);
this.Controls.Add(c);

private void Button_click(object sender, EventArgs e)


{
}
private void Button2_click(object sender, EventArgs e)
{ float n;
n = float.Parse(textBox3.Text);
n = n * 60;
label4.Text = n.ToString();
}
private void Form2_Load(object sender, EventArgs e)
{

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)


{

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)


{
if (!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar))
{ e.Handled = true; }
}

private void textBox3_TextChanged(object sender, EventArgs e)


{

private void textBox3_KeyPress(object sender, KeyPressEventArgs e)


{
char ch = e.KeyChar;
if (!char.IsDigit(ch) && ch != 8 && ch != 46)
e.Handled = true;
}

private void textBox2_KeyPress(object sender, KeyPressEventArgs e)


{
if (!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar))
{ e.Handled = true; }
}
}
}

You might also like