Visual Basic - un TextBox y Scroll

Life is soft - evento anual de software empresarial
 
Vista:

un TextBox y Scroll

Publicado por Alberto Sanchez (2 intervenciones) el 12/02/2009 10:56:25
Buenos días.
Muchas gracias por la ayuda que ofreceis y lo importante que es para todos nosotros no estar solos en esto.

ME atrevo a pediros ayuda, llevo días navegando sin exito en busca de ayuda. (Adjunto codigo vb2008) he realizado una mini aplicación para realizar mejor las pruebas.

INTENTO obtener como un visor de eventos en un Textbox para mostrar mensajes al usuario, funciona, pero no soy capaz de que la ultima linea activa sea la ultima, los mensajes se pierden por abajo y no puedo realizar un scroll automatico.
Por cierto no funciona con el form load, si creo un boton para poner mensajes, si baja hasta la ultima linea. ¿que le pasa al formload?
disculpad si me he extendido un poco.



Adjunto codigo.
=====================================
Imports System
Imports System.IO

Public Class Form1
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const WM_VSCROLL = &H115
Const SB_BOTTOM = 78

-------------------------------
Private Sub Text1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Text1.TextChanged
Text1.SelectionLength = 0
Text1.SelectionStart = Len(Text1.Text)
Text1.ScrollToCaret()
Text1.Show()
Text1.Refresh()
End Sub

----------------------------------------
Public Sub LogyEventos(ByVal linea As String)
On Error Resume Next
Dim oFecha As DateTime

Dim Sw As StreamWriter = New StreamWriter("c:logSmsActualizaciones.log", True)
Sw.WriteLine(DateTime.Now & " " & linea)
Sw.Close()
Text1.Text = Text1.Text & DateTime.Now & " " & linea & vbNewLine
Text1.SelectionLength = 0
Text1.SelectionStart = Text1.Text.Length
Text1.ScrollToCaret()
Text1.Refresh()

End Sub
------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
LogyEventos(TextBox1.Text)
End Sub
-------------------------------------
Private Sub Form1_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
LogyEventos("HOLA MUNDO")
LogyEventos("HOLA MUNDO1")
LogyEventos("HOLA MUNDO2")
LogyEventos("HOLA MUNDO3")
LogyEventos("HOLA MUNDO4")
LogyEventos("HOLA MUNDO5")
LogyEventos("HOLA MUNDO6")
LogyEventos("HOLA MUNDO7")
LogyEventos("HOLA MUNDO8")
LogyEventos("HOLA MUNDO9")
LogyEventos("HOLA MUNDO10")
LogyEventos("HOLA MUNDO11")
LogyEventos("HOLA MUNDO12")
LogyEventos("HOLA MUNDO13")
LogyEventos("HOLA MUNDO14")
End Sub

End Class
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder