Reputation: 3
Having searched around a bit, I was not able to find anything on this matter. I would like to have the items in my listbox control (CListBox) to be center aligned, is this possible?
Upvotes: 0
Views: 1419
Reputation: 1
Use LVCFMT_CENTER flag while inserting columns.
CListCtrl m_listctrl;
...
m_listctrl.InsertColumn(1, L"item_name", LVCFMT_CENTER, 40);
It doesn't, however, work for the first (inserted with index 0) column which You can insert empty colom then delete it after you insert all coloms
m_listctrl.DeleteColumn(0)
Upvotes: 0
Reputation: 6040
I think your solution is going to have to be to derive your own class from CListBox and override OnMeasureItem and OnDrawItem to draw the items centered as you want. You'll also have to make sure you create the listbox with a LBS_OWNERDRAWFIXED style.
Upvotes: 2