Dynamic selection of DataCell type for GridColumn in TreeViewGrid #2447
Replies: 2 comments
-
Update: I ended up subclassing I override the EtoOutlineDelegate.GetView() method to render a custom TableCellView view with Image and TextField for normal items, and just use the base GetView() for group items. This mostly works, as you can see below. However, I haven't managed to figure out how to prevent the textfield from getting clipped. I've set TextField.Cell wraps to false, and TextField.UsesSingleLineMode to true. Does anyone have any pointers for getting the text not to clip? Thanks! |
Beta Was this translation helpful? Give feedback.
-
Update: It turned out that even though I was using my own custom |
Beta Was this translation helpful? Give feedback.
-
Hello,
When setting up a GridColumn, is it possible to set which type of Cell is used based on what the underlying type/class of the item for a row is?
For context, what I'm trying to do is is set up a TreeGridView for use in a side bar that would match the style used in sidebars on MacOS, such that normal items would have an image/icon and text, while group items would only have text.
I know how to set up the sidebar to using Styles and setting
handler.Control.SelectionHighlightStyle <- NSTableViewSelectionHighlightStyle.SourceList
. Without icons, using justTextBoxCell
, I can get it to look something like this, which has the correct formatting for group labels and normal items:I tried to use
ImageTextCell
for all items in the column, but if I set the property for the Image on group items to null, and properly set the Image property for normal items, it doesn't render any icons at all, and the style for the text of the group items renders incorrectly.If I set the Image property for both group and normal items, then the icons render, but the formatting for the text of group items is wrong.
Ideally, I would want it to look something like what you see in Finder and other apps, where the group labels are bold gray without an icon, and the normal items have an icon and normal text:
It tried to figure out what to do following the example project at https://developer.apple.com/documentation/appkit/cocoa_bindings/navigating_hierarchical_data_using_outline_and_split_views
I
t seems, I need to set a different Cell/View type for each kind of item, as in the Swift code below:
So, Eto.Forms, would it be possible to use the GridColumn for a TreeGridView to use
TextBoxCell
for group items, but useImageTextCell
for other items? I already have different classes ofTreeGridItem
for the different kinds of items?Or would it need a CustomCell type?
I hope that make sense. Sorry for the long explanation. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions