Archive for the ‘CSharp’ Category
CSharp - Pulsación de teclas
Written by lopezatienza on 28 Octubre 2008 – 15:02 -Para saber que tecla se ha pulsado se usará el e.KeyChar.
Para que la pulsación quede invalidada o se quiera realizar una serie de métodos, pondremos la propiedad Handled así:
e.Handled = true;
private void txtNumero_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != '1' && e.KeyChar != '2' && e.KeyChar != '3' && e.KeyChar != '4' && e.KeyChar != '5' && e.KeyChar != '6' && e.KeyChar != '7' && e.KeyChar != '8' && e.KeyChar != '9' && e.KeyChar != '0')
{
e.Handled = true; 'La tecla quedaría invalidada si no es numérica
}
}
Tags: C#, CSharp
Posted in CSharp | No Comments »
CSharp - Confirmation Dialog Box ejemplo (ok, cancel)
Written by lopezatienza on 28 Octubre 2008 – 13:45 -private void button1_Click(object sender, System.EventArgs e)
{
if
(MessageBox.Show("¿Esta seguro?", "Mensaje Ventana", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{
// Aquí entraría si devuelve DialogResult.Yes
}
}
Tags: C#, CSharp
Posted in CSharp | No Comments »
Csharp - Convertir de tipo byte[] a string
Written by lopezatienza on 28 Octubre 2008 – 13:41 -Para convertir de tipo Array de byte[] a string debemos utilizar la clase System.Text, ya que tanto la clase String como la función Convert.. no permiten cambiar el tipo:
System.Text.Encoding enc = System.Text.Encoding.ASCII; 'Creamos un tipo System.Text.Encoding para poder llamar a la función
string myString = enc.GetString(myByteArray); 'Creamos un tipo string que almacenará la cadena pasada a ASCII
Tags: C#, CSharp
Posted in CSharp | No Comments »
