I have decided that I would like to have a list with "complex context", i.e. of custom-controls. (The goal is something looking like a buddy list, with photos, status-icons, text, and "start-chat-button".)
But I like it to behave as a list: scrollbars, possibility to select multiple items, etc.
When I have been looking at ListView and ListBox I only see that I can add text and an icon, but not arbitrary controls. I'm I missing how this is done?
Or should I use something else than ListView/ListBox?
Use a FlowLayoutPanel
. If you want controls arranged vertically, with scrolling, do:
myFlowLayoutPanel.AutoScroll = true;
myFlowLayoutPanel.FlowDirection = FlowDirection.TopDown;
myFlowLayoutPanel.WrapContents = false; // Vertical rather than horizontal scrolling
foreach(Control myControl in myControls){
myFlowLayoutPanel.Controls.Add(myControl);
}
Make sure the panel is large enough to contain controls and scrollbar. I'm not sure about your selection requirement.
This would be rather trivial to create in WPF (while it is going to be a lot of work in Windows Forms) - WPF is designed to create such rich-UI controls. If the rest of your app is in Windows Forms, you can host WPF control in Windows Forms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With