Author Topic: [wxSmith] Error when using wxListCtrl.  (Read 1298 times)

Offline paddle

  • Single posting newcomer
  • *
  • Posts: 4
[wxSmith] Error when using wxListCtrl.
« 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 but I am unsure if the patch have been applied or what to do to solve the issue?


Offline stahta01

  • Lives here!
  • ****
  • Posts: 6717
    • My Best Post
Re: [wxSmith] Error when using wxListCtrl.
« Reply #1 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.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
When in doubt, read the CB WiKi FAQ.

Offline Miguel Gimenez

  • Regular
  • ***
  • Posts: 398
Re: [wxSmith] Error when using wxListCtrl.
« Reply #2 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)

Offline paddle

  • Single posting newcomer
  • *
  • Posts: 4
Re: [wxSmith] Error when using wxListCtrl.
« Reply #3 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: [Select]
for ( int i = 0; i < 50; i++ )
        ListCtrl1->InsertItem(i, wxString::Format("Item %d", i));

I tried many codes

Code: [Select]
    wxListItem itemCol;
    ListView1->InsertColumn(0, itemCol);
    ListView1->SetColumnWidth(0, 100);
Code: [Select]


Code: [Select]

But no matter I always have the enclosed picture result.
« Last Edit: November 03, 2019, 12:02:13 pm by paddle »

Offline Miguel Gimenez

  • Regular
  • ***
  • Posts: 398
Re: [wxSmith] Error when using wxListCtrl.
« Reply #4 on: November 03, 2019, 01:06:26 pm »
wxListCtrl can operate in one of four modes (see for more information)
  - wxLC_LIST
  - wxLC_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: [Select]
  Report->AppendColumn("CAN Id");

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

Code: [Select]
  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.