Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: paddle on November 02, 2019, 10:14:40 pm

Title: [wxSmith] Error when using wxListCtrl.
Post by: paddle on November 02, 2019, 10:14:40 pm
When using a wxListCtrl in a wxSmith project I have this error when I launch the .exe file:

wxListCtrl style should have exactly one mode bit set

What is the problem? I seen this post https://sourceforge.net/p/codeblocks/tickets/671/ but I am unsure if the patch have been applied or what to do to solve the issue?

Thanks
Title: Re: [wxSmith] Error when using wxListCtrl.
Post by: stahta01 on November 02, 2019, 10:44:35 pm
Are you using an nightly build of Code::Blocks?
If yes, then likely patch has been applied.
If no, then no patch has been applied.

Tim S.
Title: Re: [wxSmith] Error when using wxListCtrl.
Post by: Miguel Gimenez on November 02, 2019, 11:03:37 pm
Even if the patch were applied it only prevents wxSmith from showing assertions while changing the style. Your executable will show assertions if you selected no style or more than one for the wxListCtrl; use wxSmith to assign one style or disable assertions globally (see wxWidgets documents for this)
Title: Re: [wxSmith] Error when using wxListCtrl.
Post by: paddle on November 03, 2019, 11:42:06 am
Using 17.12 release of codeblocks.

I don't really understand what are those style and how to use them. We can/should only tick on style for one wxlistctrl?

Also I just can get one column. I don't know why but my items are not setting into columns they just fill the first line, then go to the next line and so on. Also each item have a predefined lenght that I cannot find how to change. I tried using listtest sample code, but it just doesn't work in wxsmith (see enclosed picture).

Code
for ( int i = 0; i < 50; i++ )
    {
        ListCtrl1->InsertItem(i, wxString::Format("Item %d", i));
    }

I tried many codes

Code
    
    wxListItem itemCol;
    itemCol.SetText("Col1");
    itemCol.SetImage(-1);
    ListView1->InsertColumn(0, itemCol);
    ListView1->SetColumnWidth(0, 100);
Code
  
    ListView1->InsertColumn(0,_("Col1"),wxLIST_FORMAT_LEFT,100);
    ListView1->InsertItem(0,_("item1"));
    ListView1->InsertItem(1,_("item1"));
    ListView1->InsertItem(2,_("item1"));
    ListView1->InsertItem(3,_("item1"));
    ListView1->InsertItem(7,_("item1"));

    ListView1->SetItem(0,0,_("col1ItemText"));

Code
ListView1->AppendColumn("Col1");

But no matter I always have the enclosed picture result.
Title: Re: [wxSmith] Error when using wxListCtrl.
Post by: Miguel Gimenez on November 03, 2019, 01:06:26 pm
wxListCtrl can operate in one of four modes (see https://docs.wxwidgets.org/trunk/classwx_list_ctrl.html for more information)
  - wxLC_LIST
  - wxLC_REPORT
  - wxLC_ICON
  - wxLC_SMALL_ICON

You must select one (and only one) of these modes. The sample looks like a report, while your code looks like a list. You must use wxSmith to check wxLC_REPORT and uncheck the other three.

I use this code to add columns to a report:

Code
  Report->AppendColumn("CAN Id");
  Report->AppendColumn("Len");
  Report->AppendColumn("Data");

and this to add a line at the beginning of the report:

Code
  Report->InsertItem (0, "Column 0");
  Report->SetItem(0, 1,  "Column 1");
  Report->SetItem(0, 2,  "Column 2");

If you have more questions about wxListCtrl please ask in the wxWidgets forum.