01-06-2010 11:45 AM
Dear All,
I am using LabVIEW 8.2.1 and I am having the problem with cell size.
If I enter any text in a table, I need a cell size according to the text size.
I used event structure, to get the active cell, but it is giving always wrong cell data. Please let me if you have any idea.
I am attaching example.
Thanks.
01-06-2010 12:03 PM
I don't think Active Cell tells which cell changed.
I can't code up an example in lV 8.2 right now but I think I can give some pointers.
1) Mouse down will return the location
2) There is a method to convert mouse coordinates to a cell.
If you cache that away in a shift register, you could use that data in your event.
Another note!
On the Picture pallette there is a VI to insert text into a picture. It will return the number of pixels required to render your text measured in pixels.
You still have to watch out for someone tabbing through cells...
Ben
01-06-2010 12:06 PM
01-06-2010 12:09 PM
ben64 wrote:I don't think writing in a cell makes it the active cell. What you could do is compare the old and new table value to find the row and column index of the cell that was written. Then make it the active cell and modify its width. There is probably a better way to do it but that should work.
Ben
That will work but you have to be careful that both the old a new values have the same dimensions. If a new row or collumn is added, the simple "Compare if Not Equal" will only compare the parts that have the same dimensions.
But if done correctly YES that will work.
Ben
(The other Ben)
01-06-2010 01:01 PM
Ben,
Thank you for your information. But exactly I am having the problem, if both are not in (Old and NEW) same size.
Is there any way to simplify the program.
01-06-2010 01:44 PM
Since you would end up scanning the entire table anyway to find a changed value, why not autosize the entire table whenever a value is changed. Here is a quick example. I was lazy and just set the size to 7*length, you could tweak to get a reliable text length to width conversion.
I haven't patched LV2009 yet so trying to save for LV8.2 is going to either crash my LV or require too many steps for me right now. I think you get the idea.