Ver Mensaje Individual
  #9 (permalink)  
Antiguo 18/04/2011, 03:58
Denis127_2
 
Fecha de Ingreso: febrero-2011
Mensajes: 83
Antigüedad: 13 años, 3 meses
Puntos: 3
Respuesta: Descripción emergente con el contenido de un TextBox

Siento la tardanza, no se si a alguien le habría hecho falta o no...

Código Visual.NET:
Ver original
  1. Public Shared Sub añadirControlEmergente(ByVal nombre As String, ByVal txt As System.Object, ByRef controls As System.Windows.Forms.Control.ControlCollection)
  2.         'WaitSeconds(1)
  3.         'System.Threading.Thread.Sleep(1000)
  4.         Dim tamaño_ini As Integer = txt.Width
  5.         'Aproximadamente, cada caracter puede ocupar como media 7px de ancho
  6.         Dim tamaño_min As Integer = txt.Text.Length * 7
  7.  
  8.         If txt.Text <> "" And tamaño_min > tamaño_ini Then
  9.             'Solo si el control se encuentra en un contenedor que modifique el Location del control
  10.             Dim container As Control
  11.             container = txt.Parent
  12.  
  13.             Dim label As New Label
  14.             label = New Label()
  15.             label.Name = nombre
  16.             label.Text = txt.Text
  17.             label.AutoSize = True
  18.             label.BringToFront()
  19.             label.BackColor = Color.Ivory
  20.             label.BorderStyle = BorderStyle.FixedSingle
  21.             label.Location = New System.Drawing.Point(txt.Location.X + container.Location.X + 18, txt.Location.Y + container.Location.Y - 18)
  22.             controls.Add(label)
  23.             label.BringToFront()
  24.         End If
  25.     End Sub
  26.  
  27.     Public Shared Sub eliminarControl(ByRef control As String, ByRef controls As System.Windows.Forms.Control.ControlCollection)
  28.         'WaitSeconds(1)
  29.         'System.Threading.Thread.Sleep(1000)
  30.         Dim ctl As Control
  31.         For Each ctl In controls
  32.             If TypeOf ctl Is Label Then
  33.                 If ctl.Name.Equals(control) Then
  34.                     controls.Remove(ctl)
  35.                 End If
  36.             End If
  37.         Next
  38.     End Sub

Código Visual Basic:
Ver original
  1. Private Sub ratonEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ... 'EVENTOS MouseEnter
  2.  
  3.         añadirControlEmergente("EMERGENTE", sender, Me.Controls)
  4.     End Sub
  5.  
  6.     Private Sub ratonLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ... 'EVENTOS MouseLeave
  7.  
  8.         eliminarControl("EMERGENTE", Me.Controls)
  9.     End Sub
  10.  
  11.     Private Sub ratonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ...'EVENTOS MouseClick
  12.  
  13.         eliminarControl("EMERGENTE", Me.Controls)
  14.     End Sub
  15.  
  16.     Private Sub cmb_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ...'EVENTOS KeyPress de los Combobox
  17.         If not modificar then
  18.             e.Handled = True
  19.     End If
  20.         ...
  21.  
  22.     End Sub

Si alguien tiene alguna duda sobre porque he hecho lo que he hecho, que pregunt,e porque hoy no tengo tiempo de explicar ...

Saludos