Una classe con metodi statici per modificare il form dall'esterno senza istanziare nulla:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace WindowsFormsApplication4
{
class Modificatore
{
public static void modifica(Form Frm)
{
Frm.BackColor = Color.Red;
Frm.Width = 500;
Button btt = new Button();
Frm.Controls.Add(btt);
btt.BackColor = Color.Blue;
btt.Visible = true;
}
}
}
...il cui metodo statico va semplicemente chiamato dal costruttore del form:
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 WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Modificatore.modifica(this);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
Nessun commento:
Posta un commento