Refresh

Hi All,
Back again if you’ve got time :slight_smile:

I have a List Box which (essentially) draw a 10 column grid of small squares by however number of rows representing a series on contiguous dates - eg 10 Jan 2024 to 20 Jan 2024.

I have a Method called DisplayData which accesses a DB and then goes thru the records and displays a small icon representing a category of the record on the relevant date stored in the record - I hope that all makes sense.

So, if I then click on one of the icons, it brings up a (ShowPopover) window and displays the full details of the record for editing. After the window closes I want it to redo the ListBox in case the editing has moved it to a different location.

The code is in ListBox.CellPressed:

var c As new EditWindow
c.ShowPopover(Me, DesktopWindow.DisplaySides.Bottom, True, True)

DisplayData

So after I call the window, I then recall the Method. It appears to be “working” in that it updates but it does not immediately show any change. I have to click again on another cell to have the list box “redraw” correctly. I feel like it’s something to do with “Refresh” - am I on the right track?

I have tried ListBox.Refresh, ListBox.Refresh(True) and I have put them in the same area that calls the editing window after the DisplayData Method and I have tried putting them inside the Method, at the end.

I have even tried

List.Visible = False
List.Refresh(True)
List.Visible = True

I had the thought that I needed to do “something” with the ListBox to make it work.

I’m sure there is a simple way, can someone help, please??

As always, any help greatly appreciated :slight_smile:
Barry

Just a guess, but have you tried RefreshCell(Row As Integer, Column As Integer)?

Hi,
Thanks for the reply, no I hadn’t as I don’t know what cells (if any) are updated with the change. I did notice after your thoughts, that specifying -1 would cause the entire row/column to be refreshed so I tried

for i As Integer = 0 To ListBox - 1
  ListBox(i, -1)
next

:frowning: Still no good.

Can you try this?

var c As new EditWindow
c.ShowPopover(Me, DesktopWindow.DisplaySides.Bottom, True, True)

Timer.CallLater(100, AddressOf DisplayData)

Hi Jeremie,
Thanks for trying. I don’t understand what that was but tried it - still no good :frowning:

Barry

Err, has moved what to a different location?The listbox? A cell in the listbox?

Is DisplayData modifying the content of all cells in the listbox or just one. If the latter, which one? I assume the little icon is displayedd in the cell, yes?

What change are you expecting to see in the listbox after the update?

Hi Tim.
Each row in the list box represents a date. Each date could have up to 10 events occurring on that date. So I have 10 columns.
Each event is stored in the database and one of the fields is a date. So when I populate the list box, it goes thru the DB and for each event displays an icon in one of the cells in the appropriate row.

If I click on an icon, it brings up the editing window where I can edit info about that event. If I change the date, I need the icon to move to the appropriate row. I thought the easiest way was to run the method that populates the list box every time I do an edit, therefore after the editing window closes.

Now, it appears it is doing that ok, but just not showing it unless I click again on another icon in the list box. At that point it immediately redraws the whole thing.

I hope that explained it better.

I suspect that the ShowPopOver method is not synchronous, so you are doing the DisplayData call when the popover opens, not when it closes.

Try moving the DisplayData call to when you close the popover.

You should look it up.

1 Like

it seems you expect this .ShowPopover is a modal window and continue the execution of code afterwards.

i guess DisplayData is a method that should update the data after edit window.
maybe create a event devinition and call it after your Popover edit is done.

very useful for debug:

System.DebugLog CurrentMethodName
System.DebugLog "my message"

Actually I read your code too quickly and thought you were doing a ShowModal.

With ShowPopover, the popover is displayed but doesn’t stop the execution of code.

As MarkusR suggested, you could create an Event that is raised when the popover is done editing the display.
Or you could create a delegate, if you are familiar with the concept.

Hi everyone,
Thanks for all your help. I’ve solved it. I call the method that populates the list box from the editing window before it closes.

That’s fixed it but I still don’t understand why, if I put the call in the same event as the one calling the window (after it has been done), it perfoms the task but doesn’t update the view of the list box till I again click on it. One of those MANY mysteries I have to live with (as do all of you, coz I call you when I can’t figure it out) :slight_smile:

Tim - I will investigate the bit of code, I always do when you guys present me with something new :slight_smile:

Thanks everyone
Barry