Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Listview Refresh?

Posted on 2000-02-25
3
Medium Priority
?
467 Views
Last Modified: 2013-11-20
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_SUBITEM|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,&col);
}

CHeaderCtrl* pHeader1 = (CHeaderCtrl*)wndList.GetDlgItem(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,&col);
}

----------------------------------------

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!!!



0
Comment
Question by:ee_lcpaa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Expert Comment

by:VinExpert
ID: 2560577
Hi,

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->GetDlgItem(0);
      
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
0
 
LVL 3

Expert Comment

by:SamHobbs
ID: 2561060
Use DeleteColumn to Delete a Column.
0
 
LVL 3

Accepted Solution

by:
SamHobbs earned 240 total points
ID: 2561061
Instead of:

CHeaderCtrl* pHeader1 = (CHeaderCtrl*)wndList.GetDlgItem(0);

for (int kk=0;kk<5;kk++)
{
      pHeader1->DeleteItem(0);
}


Use:

for (int kk=0;kk<5;kk++)
{
      wndList.DeleteColumn(0);
}

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question