0% found this document useful (0 votes)
43 views10 pages

Nombre Del Alumno: José Alejandro Martínez Bautista Fecha: 28/10/2017 Materia: Programación 2 Trabajo

This document contains a student assignment for a Programming 2 class. The assignment involves creating programs using C# and Windows Forms. The document includes the student's name, date, and subject. It then shows the C# code for a Windows Form that allows editing text with options to change font style, color, size and more.
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)
43 views10 pages

Nombre Del Alumno: José Alejandro Martínez Bautista Fecha: 28/10/2017 Materia: Programación 2 Trabajo

This document contains a student assignment for a Programming 2 class. The assignment involves creating programs using C# and Windows Forms. The document includes the student's name, date, and subject. It then shows the C# code for a Windows Form that allows editing text with options to change font style, color, size and more.
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/ 10

NOMBRE DEL ALUMNO:

Jos Alejandro Martnez bautista


FECHA:
28/10/2017
MATERIA:
Programacin 2
TRABAJO:
programas
As para los dems formularios
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 WindowsFormsApp3
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void salirToolStripMenuItem_Click(object sender, EventArgs e)


{
Application.Exit();
}

private void colorDeLetraToolStripMenuItem_Click(object sender, EventArgs


{
var color = colorDialog1.ShowDialog();
if (color == DialogResult.OK)
{
richTextBox1.ForeColor = colorDialog1.Color;
}
}

private void colorDeFondoToolStripMenuItem_Click(object sender, EventArgs


{
var color = colorDialog1.ShowDialog();
if (color == DialogResult.OK)
{
richTextBox1.BackColor = colorDialog1.Color;
}
}

private void fuenteToolStripMenuItem_Click(object sender, EventArgs e)


{
var f = fontDialog1.ShowDialog();
if (f == DialogResult.OK)
{
richTextBox1.Font = fontDialog1.Font;
}
}

private void guardarToolStripMenuItem_Click(object sender, EventArgs e)


{
string d;
openFileDialog1.ShowDialog();
System.IO.StreamReader archivo = new
System.IO.StreamReader(openFileDialog1.FileName);
d = archivo.ReadLine();
richTextBox1.Text = d.ToString();
}
private void Form2_Load(object sender, EventArgs e)
{
comboBox1.Items.Add("10");
comboBox1.Items.Add("11");
comboBox1.Items.Add("12");
comboBox1.Items.Add("14");
comboBox1.Items.Add("16");

comboBox2.Items.Add("rojo");
comboBox2.Items.Add("negro");
comboBox2.Items.Add("azul");
comboBox2.Items.Add("amarillo");
comboBox2.Items.Add("verde");

private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)


{
string c;
c = Convert.ToString(comboBox2.Text);
if (c == "rojo")
{
richTextBox1.ForeColor = Color.Red;
}
else if (c == "negro")
{
richTextBox1.ForeColor = Color.Black;
}
else if (c == "azul")
{
richTextBox1.ForeColor = Color.Blue;
}
else if (c == "amarillo")
{
richTextBox1.ForeColor = Color.Yellow;
}
else if (c == "verde")
{
richTextBox1.ForeColor = Color.Green;
}
}

private void button1_Click(object sender, EventArgs e)


{

richTextBox1.SelectionFont = new Font(richTextBox1.Font,


FontStyle.Bold);
}

private void button3_Click(object sender, EventArgs e)


{

richTextBox1.SelectionFont = new Font(richTextBox1.Font,


FontStyle.Underline);
}

private void button2_Click_1(object sender, EventArgs e)


{
richTextBox1.SelectionFont = new Font(richTextBox1.Font,
FontStyle.Italic);
}
private void guardarToolStripMenuItem1_Click(object sender, EventArgs e)
{
string d;
openFileDialog1.ShowDialog();
System.IO.StreamReader archivo = new
System.IO.StreamReader(openFileDialog1.FileName);
d = archivo.ReadLine();
richTextBox1.Text = d.ToString();
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)


{
string d;
d = Convert.ToString(comboBox1.Text);
if (d == "10") {
richTextBox1.SelectionFont = new Font("",10); }
else if (d=="11")
{
richTextBox1.SelectionFont = new Font("", 11);
}
else if (d == "12")
{
richTextBox1.SelectionFont = new Font("", 12);
}
else if (d == "14")
{
richTextBox1.SelectionFont = new Font("", 14);
}
else if (d == "16")
{
richTextBox1.SelectionFont = new Font("", 16);
}
}
}
}

You might also like