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

Practical -1

Uploaded by

happylifehome924
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Practical -1

Uploaded by

happylifehome924
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Using Lable, TextBox and Button controls

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

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

private void showbtn_Click(object sender, EventArgs e)


{
//first
// if (this.firsttxt.Text != "")
if(this.firsttxt.Text.Length !=0)
{

// the above code is used for concatenation of string


// now we are going to add the values
int x = Convert.ToInt32(this.firsttxt.Text);
int y = int.Parse(this.secondtxt.Text);
this.resulttxt.Text = (x + y).ToString();
}
}

private void clearbtn_Click(object sender, EventArgs e)


{
//second
this.firsttxt.Text = "";
this.secondtxt.Text = "";
this.resulttxt.Text = "";

// OR
//firsttxt.Clear();
//secondtxt.Clear();
//resulttxt.Clear();
}

private void closebtn_Click(object sender, EventArgs e)


{
// Code for form closing
//this.Close();
// this.Dispose();
Application.Exit();

private void Form1_Load(object sender, EventArgs e)


{
// last step creating dynamic button

Button dynamicbtn = new Button();


dynamicbtn.Width = 90;
dynamicbtn.Height = 30;
dynamicbtn.Text = "Display";
dynamicbtn.Name = "button1";
dynamicbtn.BackColor = Color.Green;
dynamicbtn.ForeColor = Color.Red;
dynamicbtn.Location = new Point(100, 30);
dynamicbtn.Font = new Font("timenewroman", 12,
FontStyle.Italic );
Controls.Add(dynamicbtn);

//Assignment No-1: write down a program to create three buttons


dynamically at run time.

} } }

------------------------------------------------------------------------------------------------------------------------------------------

You might also like