Proportional column width

17 views
Skip to first unread message

Andreas Falkenhahn

unread,
Feb 25, 2021, 12:28:32 PMFeb 25
to wx-u...@googlegroups.com
Is there any way to make wxListView and wxDataViewCtrl columns use a width that is proportional to the widget width?

E.g. I want to have two columns and make each column use 50% of the widget width. When the user resizes the window, the columns' width should be adapted as well so that they will always be 50% of the widget width. Is there any inbuilt way to do this or do I need to override EVT_SIZE and then compute the new column width and set it in EVT_SIZE or how should that be done?

--
Best regards,
Andreas Falkenhahn mailto:and...@falkenhahn.com

Vadim Zeitlin

unread,
Feb 26, 2021, 5:17:31 PMFeb 26
to wx-u...@googlegroups.com
On Thu, 25 Feb 2021 18:29:06 +0100 Andreas Falkenhahn wrote:

AF> Is there any way to make wxListView and wxDataViewCtrl columns use a
AF> width that is proportional to the widget width?

No, there is no built-in way to do it. I thought about adding some API to
size the columns equally, as this seems like a relatively common use case,
and it could be implemented natively in the Mac version, but looking at my
own use of wxDVC I see that it's almost never as simple as that, actually,
and so finally I just keep writing ad hoc wxEVT_SIZE handlers.

AF> E.g. I want to have two columns and make each column use 50% of the
AF> widget width. When the user resizes the window, the columns' width
AF> should be adapted as well so that they will always be 50% of the widget
AF> width. Is there any inbuilt way to do this or do I need to override
AF> EVT_SIZE and then compute the new column width and set it in EVT_SIZE
AF> or how should that be done?

Yes, this is indeed exactly how it can be done.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Reply all
Reply to author
Forward
0 new messages