On Sun, 19 Nov 2006 11:28:24 +0100, Per W. wrote:
Hi, can someone help me with this? I use VB.NET and are trying to the
EM_GETLINECOUNT to count lines in a textbox. But all examples that i have
found has to problemes. as any cant be used in VS2005 and hwnd or handle,
but i cant get the textbox.hwnd og handle to work. I always get error that
hwnd or handle is not a member of system.web.ui.webcontrols.
I want a code that can read how many lines that are in use in a textbox that
are multiline and wrap enabled.
/Per W.
Option Strict On
Public Class Form1
Private Const EM_GETLINECOUNT As Integer = &HBA
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"_
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer,_
ByVal lParam As Integer) As Integer
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim Ret As Integer
Ret = SendMessage(TextBox1.Handle.ToInt32, EM_GETLINECOUNT, 0, 0)
TextBox1.Height = (Ret + 1) * TextBox1.Font.Height
End Sub
End Class
Cheers,
Gadget