ee_lcpaa
asked on
Listview Refresh?
Hi,
After inserting column into the lsitview, I want to know how can I delete this and then inserting another column...
I insert column like this:
-------------------------- ---------- ----
LV_COLUMN col;
col.mask=LVCF_FMT|LVCF_SUB ITEM|LVCF_ TEXT|LVCF_ WIDTH;
col.fmt=LVCFMT_LEFT;
for (int yk=0;yk5;yk++)
{
col.iSubItem=yk;
col.pszText="Testing";
col.cx=120;
wndList.InsertColumn(yk,&c ol);
}
CHeaderCtrl* pHeader1 = (CHeaderCtrl*)wndList.GetD lgItem(0);
for (int kk=0;kk<5;kk++)
{
pHeader1->DeleteItem(0);
}
for (yk=0;yk<NumField;yk++)
{
col.iSubItem=yk1;
col.pszText="Second";
col.cx=120;
wndList.InsertColumn(yk,&c ol);
}
-------------------------- ---------- ----
After doing this, I found even the width of my listview is enough to display the five column, the horizontal scroll bar is still appeared.
I think I cannot remove the five columns added at the first time.
Thus, I want to know how can I remove the column added and insert another new columns in my listview.
I hope the horizontal scroll bar will only be appeared if the width of the listview is not enoguh to display the five columns I added each time.
What mistake had I made?
Thanks!!!
After inserting column into the lsitview, I want to know how can I delete this and then inserting another column...
I insert column like this:
--------------------------
LV_COLUMN col;
col.mask=LVCF_FMT|LVCF_SUB
col.fmt=LVCFMT_LEFT;
for (int yk=0;yk5;yk++)
{
col.iSubItem=yk;
col.pszText="Testing";
col.cx=120;
wndList.InsertColumn(yk,&c
}
CHeaderCtrl* pHeader1 = (CHeaderCtrl*)wndList.GetD
for (int kk=0;kk<5;kk++)
{
pHeader1->DeleteItem(0);
}
for (yk=0;yk<NumField;yk++)
{
col.iSubItem=yk1;
col.pszText="Second";
col.cx=120;
wndList.InsertColumn(yk,&c
}
--------------------------
After doing this, I found even the width of my listview is enough to display the five column, the horizontal scroll bar is still appeared.
I think I cannot remove the five columns added at the first time.
Thus, I want to know how can I remove the column added and insert another new columns in my listview.
I hope the horizontal scroll bar will only be appeared if the width of the listview is not enoguh to display the five columns I added each time.
What mistake had I made?
Thanks!!!
Use DeleteColumn to Delete a Column.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What I got from that is U want to change the header's text. right?. If that is the case then do
1. Insert the columns as u R doing already.
2. Whenever U want to change the column header text do
CListCtrl *list = (CListCtrl *)GetDlgItem(IDC_LIST1);
CHeaderCtrl* pHeader = (CHeaderCtrl*)list->GetDlg
HDITEM hi;
hi.pszText = "Hello";
hi.cchTextMax = 5;
hi.mask = HDI_TEXT;
pHeader->SetItem(0, &hi);
pHeader->SetItem(1, &hi);
Thats it, U need not delete all the rows and insert the fresh ones.
Try it out.
VinExpert