LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Edit Position of MC Listbox Set to -2,-2 doesn't work

Solved!
Go to solution

I have a multicolumn listbox that has disabled, greyed out columns. I do this by discarding any click events on the columns themselves. 

 

GregFreeman_0-1689094099897.png

 

If the user presses an edit "cell", it makes that column editable

 

GregFreeman_1-1689094182161.png

 

The problem is, when I press "Save" the way I get the buttons to work is the mouse down? event is discarded so the user can't edit the text in the cell. Otherwise the default MC Listbox behavior will allow them to change the "Save" text to something else. However, if I try to set the edit cell property to -2,-2 which is supposed to be "No cell selected for editing" per the context help, it actually sets cell 0,0 to be the edit position! And if I don't change the edit position at all, i get the following, which allows a cell to continue to be edited even after save was pressed.

 

GregFreeman_2-1689094324686.png

 

 

Is there any way to easily de-activate the cell being edited? I'm starting to think simulating a click off the listbox may be the only way. I could also handle an edit event on the MC Listbox and discard it if the user changes a value in an un-editable column. But that is not ideal because the UI will be kind of confusing that way.

 

0 Kudos
Message 1 of 6
(990 Views)

Instead of alter edit position, maybe set/unset Allow Editing Cells?

 

George Zou
0 Kudos
Message 2 of 6
(960 Views)

@zou wrote:

Instead of alter edit position, maybe set/unset Allow Editing Cells?

 


 

Unfortunately that doesn't work either

0 Kudos
Message 3 of 6
(931 Views)
Solution
Accepted by topic author GregFreeman

I solved this by setting focus on the MC Listbox then using the Keybd_event function in user32.dll to send an <Enter> keystroke, which causes the user entry to be accepted.

0 Kudos
Message 4 of 6
(925 Views)

I can post my VI this evening.

Or you can try KeyFocus to other ctrls instead of simulate a click.

 

George Zou
Message 5 of 6
(921 Views)

@zou wrote:

I can post my VI this evening.

Or you can try KeyFocus to other ctrls instead of simulate a click.

 


Same issue with a Table Control and the Mouse Down Event for a similar type UI with non-editable cells. Using @zou's suggestion, that is setting KeyFocus to FALSE for the Table Control allows one click in a cell and clear any edit positions in the table.

0 Kudos
Message 6 of 6
(853 Views)