LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

A call to DeleteTextBoxLine doesn't seem to update the total number of lines in the textbox in CVI 5.01.

A call to DeleteTextBoxLine doesn't seem to update the total number of lines in the textbox in CVI 5.01. While the text is deleted on the particular, a subsequent call to GetNumTextBoxLines doesn't decrement by one line(it remains the same). IS

For example:

error=GetNumTextBoxLines(panel, textbox,&numberOfLines);
[returns 9 lines]
error=DeleteTextBoxLine(panel,textbox, numberOfLines-1) ;
error=GetNumTextBoxLines(panel, textbox,&numberOfLines);
[still returns 9 lines]

My text box lines are deleted from the bottom up, and I need to keep track of the number of lines left, and point to the end of the non-deleted text.


Any ideas?
0 Kudos
Message 1 of 4
(3,042 Views)
Ahhh, interesting problem. I have an explanation for you. If you look at the function help for DeleteTextBoxLine it says "Removes the line of text at the specified index". For every line (except the last line of the text box) this includes the text on that line and a carriage return (\r). The problem is for the last line to be removed completely, you have to remove the text on that line, and the carriage return on the PREVIOUS line. For example, if my text box contains:

Hello
World,
CVI
Rocks!

there is a /r after "Hello", "World,", and "CVI", so deleting the text on any of those lines also deletes a /r which creates a new line. But deleting the last line, remove "Rocks!", but no /r so the number of lines stays the same and the last line is blank.

If yo
u absolutely have to delete lines from the absolute bottom, the easiest way to code it would probably be to get the value of the next to last line, delete the next to last line, then set the value of the last line to the value retrieved from step 1.

Best Regards,

Chris Matthews
Measurement Studio Support Manager
Message 2 of 4
(3,042 Views)
Chris,

Thanks. I'll give that a try. I figured it was something along those lines, since I noticed later that I could delete other lines besides the last one.

Thanks again.
0 Kudos
Message 4 of 4
(3,042 Views)
Why not using a listbox instead of a text box? In a list box you can delete every line without bothering about other lines' content.
This if in your application you can use a list box instead of a text box but as I can guess your data is organized in line manner, that is your information stays in one line and don't wrap to a new one.
A listbox can add you some extra features as column separation, vertical lines, different colouring of entire lines or part of them...
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 4
(3,042 Views)