I am working on a small Eto dialog using GridView and I’m wondering if someone can give me some pointers? In particular, I’m wondering how (if?) I can add a new row to a GridView layout while its being viewed?
I am able to get the grid to show the info I want, but I’d like to be able to add to it (and someday to delete from it…) and wondering if that is possible?
Is that done by modifying the DataStore and refreshing the view somehow? I can add a single ‘blank’ row by adding a list of blank items [ ‘’, ‘’, ‘’, ‘’ ] to the DataStore prior to view, but I’d like to do that dynamically during view?
If anyone has any links, or knows any tutorials for something like that I would much appreciate it!
Hi @dale - thanks so much for getting back to me. Gotcha - so yes I can definitely do that (add to the DataStore using a click or button during run) but is there something I need to do to ‘refresh’ the window / layout after adding that? Just riffing off the example on the Rhino Developer Docs here I can certainly make a button to add to the DataStore, and it appears to register the change, but it doesn’t seem to change / adjust the Eto dialog itself?
Rather than using a simple Python list as your datastore, considering using a collection that implements the INotifyCollectionChanged interface, such as .NET’s ObservableCollection class or Eto’s FilterCollection class. These collections provide notifications when items get added, removed, or when the whole list is refreshed.
Thanks @dale , I’ll definitely take a look at those options. For now I was able to make my setup work with a dict, but followed the advice in the post here: link
move the GridView data to display out to an independant object / location
access that data each time the window builds
on click/button for add row, modify the data and then rebuild the window using a layout.Clear() and then just build it up again after the data has been changed.
I did go back and revisit this and implemented the FilterCollection in place of a regular list for the DataStore as you recommended. Worked great!
Now when the user changes any values while the window is being viewed, I can just call .DataStore.Refresh() after the changes have been made to the FilterCollection and it all updates in the GridView nicely!
Could you please re-write this code in a way that it sends a message that the “checkboxcell” is checked or unchecked on click. I have tried "OnCellEdited"for this purpose but it does not work for the checkboxcell.