LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Disable all keystrokes than numeric in multicolumnListbox

Solved!
Go to solution

I tried to catch the keystroke in key Down event with no effect. Its properly because the value are put in after the keydown event.......

Is there any other way to solve to problem?

 

 

img.jpg

img.jpg

 

0 Kudos
Message 1 of 15
(1,291 Views)

Can you attach the code so that we can reproduce your issue and understand your question better?

0 Kudos
Message 2 of 15
(1,278 Views)

Hi Michael,

 

what about a filter event ("Keydown?") to actually "Disable all keystrokes than numeric in multicolumnListbox"?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 15
(1,274 Views)

Hi both of you. Thank you for your reply.

I tried to follow your advice gerdW but apparently in the wrong way. It's possible to put in letters as well.
I uploaded my code

0 Kudos
Message 4 of 15
(1,252 Views)
Solution
Accepted by topic author Michael.Koppelgaard

Gerd meant like this.

The concept you are looking for is called "filter event". Those are the ones with a question mark at the end. They allow you to prevent further processing by wiring true to the "discard" terminal.

You will have to refine it a little because you can still input characters with the apostrophe modifier.

Message 5 of 15
(1,240 Views)
Solution
Accepted by topic author Michael.Koppelgaard

If you really only want to allow 0..9, here's what you could do.

 

altenbach_0-1678210767526.png

 

Most likely you also want to allow the period and e.g. editing keys such as <backspace> and <del>, etc.)

 

I don't understand why you would write the ItemNames property to itself. In general, listboxes are not a great way for user data input. Can you explain the purpose of all this? I am sure there is a much better way. For example, you could sense a double-click event and launch a dialog containing the current items for that value (i.e. row), allowing you to enter/OK new values in the allowed fields using numeric controls or cancel the dialog.

0 Kudos
Message 6 of 15
(1,222 Views)

@altenbach wrote:

For example, you could sense a double-click event and launch a dialog containing the current items for that value (i.e. row), allowing you to enter/OK new values in the allowed fields using numeric controls or cancel the dialog.


Here's a very simple draft for that.

altenbach_0-1678213015415.png

 

(note that you should either disable allowing to close the popup or handle the panel close event to return the input unchanged. You should also no longer allow editing the listbox directly)

 

0 Kudos
Message 7 of 15
(1,213 Views)

perfect 🙂 

0 Kudos
Message 8 of 15
(1,182 Views)

Hi Altenback. Thank you for your suggestion. I appreciate it 😉 But double clicking with a popup menu will make it more difficult to make changes isn't that correct? I just want to make changes fast and easy.

About using tables for user input: 

My purpose is to program an instrument. Water is dripping from a soil sample into a bottle.

One  bottle is under the soil sample for a period specified in “Bottle time.”
When the bottle time elapses (“current bottle time”), a new bottle is automatically put under the soil sample and the “current bottle” is incremented with 1.
When the “current bottle “ is equal to the “Number of bottles” the active line (MCL value = MCL value +1) of the MCL is changed to the next line.. “Total time” is the time for all the bottles in the line (Number of bottles” x ”Bottle time”).

The user is only allowed to enter the columns “Number of bottles” and “Bottle time”. The other columns are controlled by the program.

The number of lines in the program can change from time to time.

 

If there are any better ways to solve my problem, I'm all ears! Please let me know. I would like to learn.😊😊

Michael

0 Kudos
Message 9 of 15
(1,162 Views)

@Michael.Koppelgaard wrote:

Hi Altenback. Thank you for your suggestion. I appreciate it 😉 But double clicking with a popup menu will make it more difficult to make changes isn't that correct? I just want to make changes fast and easy.

...

 

The user is only allowed to enter the columns “Number of bottles” and “Bottle time”. The other columns are controlled by the program.

 

If you count the number of clicks needed to edit the listbox, you'll be surprised that using the popup does not really cost you more time than editing the table directly. You can easily expand the popup to add controls for two entries (number of bottles, bottle time).

 

You could even have a 2D array where you can edit all rows (two columns) in one popup.


Since the popup is using using numeric integer controls, you can even use the increment/decrement buttons to quickly adjust with the mouse, no need to detour over the keyboard and no need to validate the input (you can set the valid range in the control properties).

 

If you allow editing of the listbox directly, you need to add a lot of backend code for full functionality (Only allow certain fields to be changed, also allow editing keys (such as backspace, enter, etc.) so the user can correct directly if e.g. 999 is accidentally entered instead of 9 or to end the entry with the return key.

 

Of course you could do some elaborate detection over which field the mouse is hovering and then detect the up/down arrows to increment/decrement that field, etc. Code won't be very nice and there will be many more places for bugs to hide.

 

0 Kudos
Message 10 of 15
(1,134 Views)