27/7/07

Generar avisos de compilación en C#

Sirve para poner Wanings al darle a compilar por ejemplo para indicar cosas que quedan por hacer o pruebas en código.


private void grabacionCrear() {
#warning grabacionCrear sin hacer
}

19/7/07

Hacer un DataGridView de solo lectura.


ReadOnly = true;
AllowUserToAddRows = false;
AllowUserToDeleteRows = false;
SelectionMode = DataGridViewSelectionMode.FullRowSelect;

5/7/07

Textbox con solo números

(Copiado de www.buayacorp.com)
public Form1()
{
InitializeComponent();

textBox1.KeyPress += new KeyPressEventHandler(textBox1_KeyPress);
}
void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
// Permitir sólo las teclas de control o números
if (!(char.IsControl(e.KeyChar) || char.IsDigit(e.KeyChar)))
{
e.Handled = true;
}
}