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
Hello Peter,
After some research, the "LinesCount property for UltraTextEditor" has been determined to be a new product idea. I have sent your idea directly to our product management team.
Our product team chooses new ideas for development based on popular feedback from our customer base. Infragistics continues to monitor application development for all of our products, so as trends appear in requested features, we can plan accordingly.
We value your input, and our philosophy is to enhance our toolset based on customer feedback. If your idea is chosen for development, you will be notified at that time.
Your reference number for this product idea is PI12050061.
If you would like to follow up on your request at a later point, you may contact Developer Support management via email. Please include the reference number of your product idea in the subject and body of your email message. You can reach Developer Support management through the following email address: dsmanager@infragistics.com
Thank you for your request.
System.Windows.Forms.TextBox has a Lines count property for multiline feature,
http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.lines%28v=vs.80%29.aspx
To offer direct control replacement can't you provide the same property? Why a new property named GetLineCount?
ControlBreak said:Argh, your workaround is working fine in the sample, but it fails in my "real life project" (where controls are dynamically created :-/)
The only way I can think of that that might make a difference is if the control is not visible and so the Update method doesn't do anything. So you might need to set Visible to true. You might also want to check IsHandleCreated on the control. If there's no handle, then Update probably won't work, either. In such a case, you could hook into the control's HandleCreated event and then get the line count and size the control at that point.
Argh, your workaround is working fine in the sample, but it fails in my "real life project" (where controls are dynamically created :-/)
I will mark your answer as accepted anyway, since it's the explanation about what is happening. I will try to build another prototype as soon I have some time and post it here later.
Hello Torrey, I already tried this kind of solution, I mean, counting \n in the string, unfortunately it does not fit here : the size of the box also depends on its width and the way words inside are wrapped, regardless there are \n or not.