lxn / walk

A Windows GUI toolkit for the Go Programming Language
Other
6.78k stars 885 forks source link

Styling list items #755

Closed alkanna closed 3 years ago

alkanna commented 3 years ago

I'm trying to color my list items according to each item's field.

type InventoryModel struct {
    walk.ListModelBase
    Items []models.Item // <-- these
}

I found out that I can set an ItemStyler for my ListBox, but from there what should to do is quite obscure.

I looked through the models and I can see I have to implement ListItemStyler and ListItemStyle, however, I am quite stuck as I feel like I would need to kind of reinvent the wheel by doing that, while I just want to apply a LineColor to my items.

Is there a preferred way to do that, or am I diving into a big chunk of code for a simple thing ?

lxn commented 3 years ago

Please have a look at the listbox_ownerdrawing and tableview examples for this.

alkanna commented 3 years ago

I'm so sorry I missed that. Cheers I think I might have to make a PR with some documentation layout to redeem myself :)