Sunteți pe pagina 1din 18

HOME-WORK 3

MODERN WEB PROGRAMMING TOOLS AND


TECHNIQUES II
SUBMITTED TO:
MS JASVEEN KALRA

SUBMITTED BY:
RAJESH RANA
ROLL NO. 16
REG. NO. 7010070005
BCA (H) – MCA

LOVELY PROFESSIONAL UNIVERSITY


PART A

1. Write a Program to copy content of a list box to another

list box.

Ans. 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 List_Box_Copy

public partial class Form1 : Form

public Form1()
{

InitializeComponent();

private void Form1_Load(object sender, EventArgs e)

listBox1.Items.Add("Rajesh");

listBox1.Items.Add("Rana");

listBox1.Items.Add("D37d2");

listBox1.Items.Add("LPU");

listBox1.Items.Add("LSTEA");

private void button1_Click(object sender, EventArgs e)

foreach (string s1 in listBox1.Items)

listBox2.Items.Add(s1);

}
}

2. Write a program to implement namespaces.

Ans. using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace Namespaces

namespace student

class check

public check()

Console.WriteLine("Hello from namespace student");

}
}

namespace school

class check

public check()

Console.WriteLine("Hello From Namespace School");

class Program

static void Main(string[] args)

student.check obj = new Namespaces.student.check();

school.check obj1 = new Namespaces.school.check();

Console.ReadLine();

}
}

Output :-

3. Write a program to explore files from disk drives using

drive, directory and file list box controls.

Ans. 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 WindowsFormsApplication1

public partial class Form1 : Form

public Form1()

InitializeComponent();

private void button1_Click(object sender, EventArgs e)

if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)

string s = folderBrowserDialog1.SelectedPath;

listBox1.Items.Add(folderBrowserDialog1.RootFolder);

listBox2.Items.Add(folderBrowserDialog1.SelectedPath);
}

private void Form1_Load(object sender, EventArgs e)

Output :-
PART B

4. Compare and Contrast the Name and Text Property of

textbox control.

Ans.

Name Property Text Property

1. The Name property can be 1. Gets or sets the text content of the
used at run time to evaluate TextBox control.

the object by name rather

than type and programmatic

name

3. By using Properties name is 3. By using properties name is changed

changed :- :-
5. Using rich Text box, create an editor and Open an existing

file using OpenFileDialog box then write some text on that

file and save same file using SaveFileDialog box.

Ans. 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;

using System.IO;

namespace Open_and_save_a_file

public partial class Form1 : Form

public Form1()

{
InitializeComponent();

private void openFileDialog1_FileOk(object sender,


CancelEventArgs e)

private void button1_Click(object sender, EventArgs e)

//openFileDialog1.Filter = "Text File (*.txt)|*.txt|All Files|*.*";

if (openFileDialog1.ShowDialog() == DialogResult.Cancel)

richTextBox1.Text =
File.ReadAllText(openFileDialog1.FileName);

private void button2_Click(object sender, EventArgs e)

if (saveFileDialog1.ShowDialog() == DialogResult.OK)

Response.ContentType = "abc.txt";
Response.AppendHeader("Content-Disposition", "attachment;
filename=abc.txt");

Response.TransmitFile(Server.MapPath("~/abc/"));

Output :-
6. Using rich Text box, create an editor and perform font and

color setting of text using font and color dialog boxes.

Ans. 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 WindowsFormsApplication1

public partial class Form1 : Form

public Form1()

InitializeComponent();

private void button1_Click(object sender, EventArgs e)

colorDialog1.ShowDialog();

richTextBox1.BackColor = colorDialog1.Color;

private void button2_Click(object sender, EventArgs e)

colorDialog1.ShowDialog();
richTextBox1.ForeColor = colorDialog1.Color;

private void button3_Click(object sender, EventArgs e)

FontDialog f1 = new FontDialog();

f1.ShowDialog();

richTextBox1.Font = f1.Font;

private void fontDialog1_Apply(object sender, EventArgs e)

Output :-
To Change Back Color :-

To Change Text Color :-


To Change Font :-

S-ar putea să vă placă și