wxDataViewTreeCtrl second column disappear Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
liberbear
In need of some credit
In need of some credit
Posts: 5
Joined: Tue Mar 23, 2021 7:25 am

wxDataViewTreeCtrl second column disappear

Post by liberbear »

Hello,

In my code i use something like this (from examples).
And it works. But unfortunately value in second column disappear when item has childs.
How to prevent this? I want to show values in all columns

Code: Select all

void MyMusicTreeModel::GetValue( wxVariant &variant, const wxDataViewItem &item, unsigned int col ) const
{
    wxASSERT(item.IsOk());

    MyMusicTreeModelNode *node = (MyMusicTreeModelNode*) item.GetID();
    switch (col)
    {
    case 0:
        variant = node->m_title;
        break;
    case 1:
        variant = node->m_artist;
        break;
    case 2:
        variant = (long) node->m_year;
        break;
    case 3:
        variant = node->m_quality;
        break;
    case 4:
        variant = 80L;  // all music is very 80% popular
        break;
    case 5:
        if (GetYear(item) < 1900)
            variant = "old";
        else
            variant = "new";
        break;

    default:
        wxLogError( "MyMusicTreeModel::GetValue: wrong column %d", col );
    }
}
Attachments
Annotation 2021-07-15 111609.png
Annotation 2021-07-15 111609.png (12.56 KiB) Viewed 1585 times
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxDataViewTreeCtrl second column disappear

Post by doublemax »

That is controlled by the wxDataViewModel and you'll have to override wxDataViewModel::HasContainerColumns().
https://docs.wxwidgets.org/trunk/classw ... 9caaec3c3d
Use the source, Luke!
liberbear
In need of some credit
In need of some credit
Posts: 5
Joined: Tue Mar 23, 2021 7:25 am

Re: wxDataViewTreeCtrl second column disappear

Post by liberbear »

doublemax wrote: Thu Jul 22, 2021 8:43 am That is controlled by the wxDataViewModel and you'll have to override wxDataViewModel::HasContainerColumns().
https://docs.wxwidgets.org/trunk/classw ... 9caaec3c3d
Oh, it works!

Thank you very much
Post Reply