![]() |
How to change color and font of CXTListView? |
Post Reply
|
| Author | |
cxmvip
Newbie
Joined: 28 June 2007 Location: China Status: Offline Points: 12 |
Post Options
Thanks(0)
Quote Reply
Topic: How to change color and font of CXTListView?Posted: 04 July 2007 at 12:55am |
|
I creat a MDI and want to change one row's text color and font of the CXTListView.My code is that: CMyView:public CXTListView
{
void initializeListCtrl();
}
...
In the member funtion initializeListCtrl():
void CMyView::InitializeListControl()
{ // build a date string to insert into the list control. CTime tm = CTime::GetCurrentTime(); CString strTime; strTime.Format(_T("%d-%2d-%2d %2d:%2d:%2d"), tm.GetYear(),tm.GetMonth(), tm.GetDay(),tm.GetHour(),tm.GetMinute(),tm.GetSecond() );
// set the image list for the list control. CListCtrl& rList = GetListCtrl(); rList.SetImageList(&m_imageList, LVSIL_SMALL); // CXTListCtrl m_listCtrl; // &m_listCtrl=(CXTListCtrl)&rList; int m_i_ctrlID=rList.GetDlgCtrlID(); // insert the first item. rList.InsertItem(0, NULL, 0); rList.SetItemText(0, 1, _T("Read")); rList.SetItemText(0, 2, _T("IBM")); rList.SetItemText(0, 3, _T("0.23")); rList.SetItemText(0, 4, strTime); rList.SetItemText(0, 5, _T("1")); // inset the second item.
strTime.Format(_T("2007-10-12 12:12:12")); rList.InsertItem(1, NULL, 1); rList.SetItemText(1, 1, _T("Unread")); rList.SetItemText(1, 2, _T("MS")); rList.SetItemText(1, 3, _T("12.32")); rList.SetItemText(1, 4, strTime); rList.SetItemText(1, 5, _T("12")); // inset the third item.
strTime.Format(_T("2007-8-12 13:13:13")); rList.InsertItem(2, NULL, 0); rList.SetItemText(2, 1, _T("Read")); rList.SetItemText(2, 2, _T("Codejock")); rList.SetItemText(2, 3, _T("2.67")); rList.SetItemText(2, 4, strTime); rList.SetItemText(2, 5, _T("6")); SetRowColor(1, RGB(0,0,0), RGB(255,0,0));
EnableUserSortColor(true);
// enable autosizing for columns.
m_flatHeader.EnableAutoSize(); // lock the first two colums from sizing operations.
m_flatHeader.FreezeColumn(0); m_flatHeader.FreezeColumn(1); } But I cann't change the color of the second row!
By the way,how can I change the font of one row?
|
|
|
bird
|
|
![]() |
|
cxmvip
Newbie
Joined: 28 June 2007 Location: China Status: Offline Points: 12 |
Post Options
Thanks(0)
Quote Reply
Posted: 08 July 2007 at 11:53pm |
|
I have solved to change the color .
But it can't show correctly when it 's sorted!
How can I do?
By the way,How can I change the font of one row?
|
|
|
bird
|
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |