TreeGridView: preventing SelectedRows from changing when clicking on (certain) cells

Hi all,

When one clicks on a cell in a TreeGridView, the cell’s row is selected (turns blue), and all others are deselected by default. What’s the best way to override this? I’m trying to mimic the behavior of most of the columns in Rhino’s layer table (color, material, etc.) – which handle click events by, say, opening a dialog but keeping the SelectedRows list as is (if the clicked row was already selected). This of course allows the user to understand which rows are being edited.



Hi @sarg,

The Layer panel’s control owner draws everything. I’m not sure how this is done in Eto. Perhaps @curtisw, can give us some wisdom.

– Dale

Thanks Dale. Whatever implements the selection change appears to be downstream of TreeGridView’s OnCellClick() override, so looks like I can circumvent it as needed by invalidating the control before exiting that method. Not sure this is “best practice” but seems to do the trick for now.

Hey @sarg,

One way you can override the click behaviour of the TreeGridView is to use the MouseDown event and set the Handled property of the event arguments to true. You can use the GetCellAt(e.Location) to get which cell the user clicked on. We do that for the lights panel (on Mac) and other places.

For example:

myTreeGridView.MouseDown += (sender, e) => {
  var cell = myTreeGridView.GetCellAt(e.Location);
  // do something with the cell, cell.Item will be the TreeGridItem, etc.
  e.Handled = true;

Hope this helps!

Perfect, much cleaner.

Thanks @curtisw!