Está en la página 1de 19

2011- I MODULO

LENGUAJE DE PROGRAMACIN VISUAL


UNIDAD DIDACTICA V APLICAIONES WINDOWS FORM

Control ListView

Control ListView
1. AGREGAR DATOS A LAS COLUMNAS: clic en la propiedad Columns
2. Luego agregamos las columnas, modificamos la propiedad text y witch, segn la necesidad 3. Para que aparezca todo el registro seleccionado, modificamos la propiedad fullrowselectec a TRUE

Agregar Valores
Dim lwItem As ListViewItem

lst.Items.Clear() For i As Integer = 0 To 5 lwItem = lst.Items.Add(InputBox("INGRESE NOMBRE"), 0) lwItem.SubItems.Add(InputBox("INGRESE NOTA")) lwItem.SubItems.Add(InputBox("INGRESE NOTA")) Next

Obtener valores del ListView


Public Sub sumar() Dim i As Integer Dim suma As Integer For i = 0 To lst.Items.Count 1 suma = suma + Int32.Parse(lst.Items(i).SubItems(1).Text) Next Me.txtsuma.Text = suma End Sub

Eliminar valores del ListView


Dim i As Integer For i = 0 To lst.Items.Count - 1 If lst.Items(i).Selected = True Then lst.Items(i).Remove() Exit For End If Next

Eliminar valores del ListView


Dim i As Integer For i = 0 To lst.Items.Count - 1 If lst.Items(i).Checked = True Then lst.Items(i).Remove() End If If lst.Items.Count - 1 = i Then Exit For End If Next

Image List y ListView

Image List y ListView

Pulsacin de tecla
Evento keypress

If Asc(e.KeyChar) = 13 Then Me.txtTelefono.Focus() End If


Evento KeyDown If e.KeyCode = Keys.Return Then MostrarDatos() End If End Sub

Pulsacin de tecla
e.KeyChar: Esta instruccin nos devuelve el carcter que ha sido digitado en ese momento, por ejemplo si digitamos la letra .a., esta instruccin nos devuelve el valor de a pero como carcter. Asc: Esta funcin convierte cualquier carcter enviado en un cdigo ASCII , siguiendo del ejemplo anterior, ya que e.KeyChar tiene el carcter de a, si esto lo enviamos a la funcin Asc, quedara mas o menos as: Asc(e.KeyChar), esta instruccin nos devolvera el valor de 97, porque, bueno el valor de a en cdigo ASCII es 97, as de simple. e.Cancel: Esta instruccin nos permite cancelar cualquier evento que se este realizando, por ejemplo si estamos cerrando el formulario, podemos indicarle que lo cancele, envindole o instancindole un valor verdadero, para la cancelacin del evento.

Formato
Dim Numero As Double Numero = 100000/3 Me.Label1.Text = Format(Numero, "###,##0.00")

Picture Box
Como lo he mencionado antes, este control PictureBox nos permite mostrar imgenes ya seas *.bmp, *.jpg, *.gif, *.png, etc. Las propiedades mas usadas de este control son: BackColor; la mayora de veces la usamos para ponerle un color de fondo al control, el color mas usado es el transparente.

SizeMode; nos indica como se adecua la imagen ante el control, ya sea estirarlo o mejor dicho auto ajustar, tamaa original, Zoom y centrado.
BackgrounImageLayout; nos indica la forma en que se mostrara la imagen, ya sea en mosaico, centrado, estirado o Zoom. Image; aqu establecemos la imagen a mostrar en el tiempo de ejecucin del programa.

ListBox y ComboBox
Para aadir a un elemento ListBox1.Items.Add(Cadena de Texto) ComboBox1.Items.Add(Cadena de Texto) Para eliminar un elemento ListBox1.Items.Remove(Numero del Elemento a Eliminar) ComboBox1.Items.Remove(Numero del Elemento a Eliminar) Para saber que elemento se ha seleccionado Variable = ListBox1.SelectedIndex() Variable = ComboBox1.SelectedIndex()

ListBox y ComboBox
Para Saber el Numero de los Elementos de la Lista Variable = ListBox1.Items.Count() Variable = ComboBox1.Items.Count() Para seleccionar un Elemento

ListBox1.SelectedIndex = Numero del Elemento a seleccionar ComboBox1.SelectedIndex = Numero del Elemento a seleccionar

Sincronizar ListBox y ComboBox


lstCantidad (Evento SelectedIndexChanged) Dim Index As Integer Index = Me.lstCantidad.SelectedIndex Me.lstDescripcion.SelectedIndex = Index Me.lstPrecUnit.SelectedIndex = Index Me.lstTotal.SelectedIndex = Index Me.btnEliminar.Enabled = True lstDescripcion (Evento SelectedIndexChanged)

Dim Index As Integer Index = Me.lstDescripcion.SelectedIndex Me.lstCantidad.SelectedIndex = Index Me.lstPrecUnit.SelectedIndex = Index Me.lstTotal.SelectedIndex = Index Me.btnEliminar.Enabled = True

Sincronizar ListBox y ComboBox


lstPrecUnit (Evento SelectedIndexChanged) Dim Index As Integer Index = Me.lstPrecUnit.SelectedIndex Me.lstDescripcion.SelectedIndex = Index Me.lstCantidad.SelectedIndex = Index Me.lstTotal.SelectedIndex = Index Me.btnEliminar.Enabled = True lstTotal (Evento SelectedIndexChanged)

Dim Index As Integer Index = Me.lstTotal.SelectedIndex Me.lstDescripcion.SelectedIndex = Index Me.lstPrecUnit.SelectedIndex = Index Me.lstCantidad.SelectedIndex = Index Me.btnEliminar.Enabled = True

Operaciones ListBox y ComboBox


btnCancelar (Evento Click) Dim Index As Integer Index = Me.lstCantidad.Items.Count - 1 Me.lstCantidad.Items.RemoveAt(Index) Me.lstDescripcion.Items.RemoveAt(Index) Me.lstPrecUnit.Items.RemoveAt(Index) Me.lstTotal.Items.RemoveAt(Index)

btnEliminar (Evento Click)


Dim Index As Integer Index = Me.lstCantidad.SelectedIndex Me.lstCantidad.Items.RemoveAt(Index) Me.lstDescripcion.Items.RemoveAt(Index) Me.lstPrecUnit.Items.RemoveAt(Index) Me.lstTotal.Items.RemoveAt(Index)

Limpiar
Public Sub BLANQUEAR() Dim varControl As Object For Each varControl In Me.Controls If varControl.Tag = "Campo" Then varControl.Text = "" End If Next varControl End Sub Public Sub ACTIVAR_CAMPOS(ByVal Modo As Boolean) Dim varControl As Object For Each varControl In Me.Controls If varControl.Tag = "Campo" Then varControl.Enabled = Modo End If Next varControl End Sub

También podría gustarte