Archicad C++ API
About Archicad add-on development using the C++ API.

[SOLVED] SingleSelListBox header

Anonymous
Not applicable
Hello

How to set up header columns?
I'm doing the following but it shows the first column only

lbNodes.SetHeaderItemCount(5);

lbNodes.SetHeaderItemSize(1, 50);
lbNodes.SetHeaderItemSize(2, 50);
lbNodes.SetHeaderItemSize(3, 50);
lbNodes.SetHeaderItemSize(4, 50);
lbNodes.SetHeaderItemSize(5, 50);

lbNodes.SetHeaderItemText(1, "Name");
lbNodes.SetHeaderItemText(2, "User");
lbNodes.SetHeaderItemText(3, "CPU");
lbNodes.SetHeaderItemText(4, "GPU");
lbNodes.SetHeaderItemText(5, "GPU Load");


lbNodes.AppendItem ();
lbNodes.SetTabItemText(DG::ListBox::BottomItem, 1, "server1");
lbNodes.SetTabItemText(DG::ListBox::BottomItem, 2, "user1");
lbNodes.SetTabItemText(DG::ListBox::BottomItem, 3, "1");
lbNodes.SetTabItemText(DG::ListBox::BottomItem, 4, "2");
lbNodes.SetTabItemText(DG::ListBox::BottomItem, 5, "50%");
4 REPLIES 4
Oleg
Expert
I think you dont need to use SetHeaderItemCount and SetHeaderItemSize.

Look at SetTabFieldCount and SetTabFieldProperties.
ReignBough
Enthusiast
I have something like this:
SomeTabPage::SomeTabPage(...) : ...
  lstItem(GetReference(), DG::Rect(), DG::ListBox::VScroll, DG::ListBox::NoPartialItems, DG::ListBox::Header, 25)
{
  // ...
  const short tabCnt = 5;
  lstItem.SetTabFieldCount(tabCnt);

  lstItem.SetPosition(xpos, ypos);
  lstItem.SetSize(itmWd, itmHt);
  lstItem.SetFontSize(DG::Font::Small);
  short tabTotWidth = wd - 21; // scroll width
  short tabIdx = 1;
  short tabWid = 15;
  short tabBeg = 0;
  short tabEnd = tabBeg + tabWid;
  lstItem.SetTabFieldProperties(tabIdx, tabBeg, tabEnd, DG::ListBox::Center, DG::ListBox::EndTruncate, true, true);
  lstItem.SetHeaderItemText(tabIdx, "head 1");
  // other header settings here
  // populate list box after
  // ...
}
But the list box is not showing. When I removed the header flag, the list will be created (of course) with no header.

EDIT
I also tried doing as simple as this:
lstItem.SetPosition(xpos, ypos);
lstItem.SetSize(itmWd, itmHt);
lstItem.SetFontSize(DG::Font::Small);
lstItem.Show();
Shows (without header) when header flag is not set; otherwise, no list box is generated.

EDIT 2
I tried calling HasHeader() and it returns false whether header flag is set or not. Is this a bug?
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
Mihaly Palenik
Graphisoft
Graphisoft
Hello,

the problem is in the initializer list. lstItem size is 0,0 because of DG::Rect() but you'd like to set header size to 25. That's why lstItem isn't created because its invalid state.

You should add initial size which height is more than 25:
 
SomeTabPage::SomeTabPage(...) : ... 
  lstItem(GetReference(), DG::Rect(DG::Point (0, 0), DG::Point (100, 100)), DG::ListBox::VScroll, DG::ListBox::NoPartialItems, DG::ListBox::Header, 25) 
{ 
    // ... 
 
    // modify size if initial one isn't appropriate 
    lstItem.SetSize(itmWd, itmHt); 
     
    //... 
} 
ReignBough
Enthusiast
Thanks, Mihály Palenik. Most of the dialog items are fine when initialized with DG::Rect() (no parameter). And set its size on the body. Now it is working. Thanks again.
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS