User forums > Using Code::Blocks

[wxSmith] Error when using wxListCtrl.

(1/1)

paddle:
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

stahta01:
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.

Miguel Gimenez:
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)

paddle:
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));
    }

--- End code ---

I tried many codes


--- Code: ---   
    wxListItem itemCol;
    itemCol.SetText("Col1");
    itemCol.SetImage(-1);
    ListView1->InsertColumn(0, itemCol);
    ListView1->SetColumnWidth(0, 100);
--- End code ---

--- 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"));
--- End code ---


--- Code: ---ListView1->AppendColumn("Col1");

--- End code ---

But no matter I always have the enclosed picture result.

Miguel Gimenez:
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");

--- End code ---

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");

--- End code ---

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

Navigation

[0] Message Index

Go to full version