i can right-aligne columns 1 and 2 without problems,
but column 0 is always Left-aligned regardless which alignement flags i send,
someone who knows a workaround ?
i'm using wxMSW-2.6.2
this is the modified code from the listctrl sample:
Code: Select all
void MyFrame::InitWithReportItems()
{
m_listCtrl->SetImageList(m_imageListSmall, wxIMAGE_LIST_SMALL);
// note that under MSW for SetColumnWidth() to work we need to create the
// items with images initially even if we specify dummy image id
wxListItem itemCol;
itemCol.SetText(_T("Column 1"));
itemCol.SetImage(-1);
itemCol.SetAlign(wxLIST_FORMAT_RIGHT); // <-- doesn't work, always left aligned ;-(
m_listCtrl->InsertColumn(0, itemCol);
itemCol.SetText(_T("Column 2"));
itemCol.SetAlign(wxLIST_FORMAT_CENTRE);
m_listCtrl->InsertColumn(1, itemCol);
itemCol.SetText(_T("Column 3"));
itemCol.SetAlign(wxLIST_FORMAT_LEFT);
m_listCtrl->InsertColumn(2, itemCol);
// to speed up inserting we hide the control temporarily
m_listCtrl->Hide();
wxStopWatch sw;
for ( int i = 0; i < NUM_ITEMS; i++ )
{
m_listCtrl->InsertItemInReportView(i);
}
m_logWindow->WriteText(wxString::Format(_T("%d items inserted in %ldms\n"),
NUM_ITEMS, sw.Time()));
m_listCtrl->Show();
// we leave all mask fields to 0 and only change the colour
wxListItem item;
item.m_itemId = 0;
item.SetTextColour(*wxRED);
m_listCtrl->SetItem( item );
item.m_itemId = 2;
item.SetTextColour(*wxGREEN);
m_listCtrl->SetItem( item );
item.m_itemId = 4;
item.SetTextColour(*wxLIGHT_GREY);
item.SetFont(*wxITALIC_FONT);
item.SetBackgroundColour(*wxRED);
m_listCtrl->SetItem( item );
m_listCtrl->SetTextColour(*wxBLUE);
m_listCtrl->SetBackgroundColour(*wxLIGHT_GREY);
m_listCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
m_listCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
m_listCtrl->SetColumnWidth( 2, wxLIST_AUTOSIZE );
// test SetItemFont too
m_listCtrl->SetItemFont(0, *wxITALIC_FONT);
}