LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Possible to have a table control that takes numbers only?

Is it possible to create a table control to take numbers only?  I know it is possible to have a two dimensional array of numbers but the user interface for the table is a much better usere experience.  The keyboard navigation and the ability to have different length columns are key features.

 

 

John

0 Kudos
Message 1 of 11
(6,082 Views)

I've limited inputs before by just programmatically changing them back (or removing offending characters) once the user has triggered a Value Change event. You might even be able to do it with a Key Down event.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 11
(6,077 Views)
You can do it with the Key Down? Filter event. You have to remember to handle all the key strokes that are useful like backspace, tab and the arrow keys. It's not trivial, but it's not rocket science either.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 11
(6,042 Views)

You can start here, but invert the logic.

 

However, this can be difficult. Make sure you don't disable editing keys such as left/right arrow, backspace, delete, etc. Also remember to allow the decimal point as well as the "E" or "e" in case the user enters number in exponential format (e.g. 1E5 for 10000). You might also want to allow SI units, such as "1M" for 1e6, "1n" for 1e-9, etc.  Regular numerics allow all that!

 

 

 

 

0 Kudos
Message 4 of 11
(6,002 Views)
A trick that I have used for validating numbers is when leaving the cell, format the string they have entered as a number, and then back into a string and write that string into the cell.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 11
(5,980 Views)

@mikeporter : "It's not trivial, but it's not rocket science either."

 

I am Belgian (I speak French) ... i like this expression.     Smiley Very Happy

0 Kudos
Message 6 of 11
(5,966 Views)
The way I have done it in the past was to actually use hidden controls for it, then LabVIEW does all the work of figuring out what's valid. Numbers specifically can get tricky as "e" for example is valid. LabVIEW will also allow for scientific prefixes such as "m" and "k". I had a mixed table (I used a listbox for aesthetic reasons, but it's the same idea). So, I had a string control, a numeric control, a boolean, and a ring control. All were hidden from view until the user clicked on the cell. Then, based on where the click was, I resized the control for that cell, and displayed it right where the cell was, so it didn't look like I popped a control on top of the listbox. I was using system controls, so they tended to merge a little better than the silver or modern controls might, but I think you can still get it to work. Once the user entered the data, I would fill the cell in the listbox and hide the control again. It really ended up working pretty well, and it was much easier to move and resize the control (in my opinion) than to manipulate the keystrokes. And, as I mentioned, in my case, I needed more than just numeric entry, and once you write the code for determining size and location, it is quite easy to expand to add other data types.
Message 7 of 11
(5,936 Views)

I was hoping to find my original code, but It was taking too long to track down, so I just made another example just for the numeric.

 

I like using listboxes, as I said, due to aesthetics, but also because they have some more events available to them, which I utilize here.  You could certainly do this for a table if you wish, but it may not be as easy.

 

There is a shortcut I made here that I would not do in a final implementation.  I am converting the number to a string and back again for editing the cell.  I typically would store the data in its native format and only convert to the string data so I don't lose anything to rounding.  Here, I am only showing one decimal point, and so if I type in a value with more than one decimal, the information is permanently lost due to this example.

Message 8 of 11
(5,873 Views)

e.g. 1E5 for 10000

 

Nobody should enter "1e5" when they mean "10000".

😉

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 9 of 11
(5,841 Views)

@CoastalMaineBird wrote:

e.g. 1E5 for 10000

 

Nobody should enter "1e5" when they mean "10000".

😉


Exactly. I would just enter 10k! 😄

0 Kudos
Message 10 of 11
(5,825 Views)