On a TextBox I can calculate the number on lines with the following code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged linecount = SendMessage(TextBox1.Handle.ToInt32, EM_GETLINECOUNT, -1, 0) lblLine1.Text = "Line Count: " & (linecount).ToString lblLine2.Text = "Char Count: " & TextBox1.Text.Length If linecount > 6 Then TextBox1.Focus() SendKeys.Send("{BKSP}") End If End Sub
When I use an UltraTextEditor control the code does not work.
I need to restrict the number the lines. Is there a way to do this?
John
John;
I'd like to use your code, with the .Controls[0] modification...what's the declaration for EM_GETLINECOUNT?
Do I need a Using System.xml or something ?
Thanks.
Harry Gross
Hi Harry,
In NetAdvantage 2010 Volume 2, we added support for GetLineCount and some other SendMessage calls on our editor controls. So you can now use them directly.
Anyway... I don't think I have a sample of the syntax for this. I recommend checking out Microsoft's documentation on calling API's from DotNet. Or just do a search on the web, there are a few sites out there that have already written the declarations of these API's for you.
Also note that the API you are looking for here is SendMessage. EM_GETLINECOUNT is the message you will send, not the API itself.