How to right align the text within CListBox
Printable View
How to right align the text within CListBox
If you use "Report" style for your ListBox, you can right align each column text except the first column. When you create the column headers for the ListCtrl, just use the following flag for the column alignment:
LV_COLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH |
LVCF_TEXT | LVCF_SUBITEM;
lvc.cx = 60; // width of first column
lvc.fmt = LVCFMT_RIGHT; // align right
for(int i=0; i < 4; i++){
lvc.iSubItem = i;
lvc.pszText = ColumnLabel[i];// Label
m_list.InsertColumn(i,&lvc); // insert it
}
Hope this will help. Good luck.
Lynx
Add WS_EX_RIGHT extended style to the ListBox.
CListBox MyListBox;
SetWindowLong(MyListBox.m_hWnd, GWL_EXSTYLE, WS_EX_RIGHT)
Also from resources you can go to properties/Extedned Styles and set Right aligned text.