Un-highlighting a row on a grid

Thanks to @ratslinger, I was able to highlight a specific row on a grid/table control. However, the row that was already highlighted is still highlighted, so I end up with 2 highlighted rows when I only want 1. I don’t want 2 rows competing for the user’s attention.

Web searches have turned up nothing about using code to remove highlighting. Text searches in LOBG and Pitanyak haven’t returned anything. I haven’t found anything in Dbg_Properties and Dbg_Methods that looks promising.

Can anyone offer a starting point for writing code that removes highlighting?

Found the answer from @Ratslinger in this great post.

@sokol92, I appreciate you making the effort to find this. However, this line

oTableView.Select(sel)

highlights the specified row. I don’t see anything that removes highlighting.

Try
oTableView.select(array())

1 Like

Let’s check.
In the attached file from @Ratslinger , I added a button that selects records 5 and 6. After clicking it, there are no other selected records.
You can try to select some records and press the specified button.

GridSelection.odb (15.6 KB)

@sokol92, I tried using the select method to unselect a few days ago, and it didn’t unselect. I tried it again after seeing your reply, and it still didn’t work. I didn’t bother looking at your file. I assume it does what you say it does. After thinking it over, I realized that after the user clicks on a row, my procedure runs before LO applies the highlighting, which means that the highlighting is applied at a time when it overrides anything the select method does in my procedure.

I moved the procedure to a different event, and the select method works fine. I put both the user selected row and the row I want to highlight into the selection array, and the select method toggles the user selected row off and my row on, all in one procedure call. Very cool.

Unfortunately, moving the procedure creates new problems. It was running in a particular event for a reason, and it doesn’t do the job if it runs in another event. I’ve also discovered that implementing complicated business rules and data validation rules in a grid leads to forms loading data erratically and/or frequent crashes. Offloading the processing onto stand-alone controls works more reliably.

Thanks for your comments. You were right about the select method. But this was an experiment that didn’t work out.