Home > Software engineering >  Why do I use m_list DeleteAllItems (); No effect
Why do I use m_list DeleteAllItems (); No effect

Time:09-21

A refresh button
 void main: : OnBnClickedButton1 () 
{
m_list.DeleteAllItems();
M_list. SetExtendedStyle (m_list. GetExtendedStyle () | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
//initialize
Cstrings field []={TEXT (" serial number "), TEXT (" product name "), TEXT (" food price "), TEXT (" remaining quantity ")};

for(int i=0; i{
M_list. InsertColumn (I, field [I], LVCFMT_CENTER, 100);
}

Cinfo file;
File. ReadDocline ();//read information
int i=0;
Cstrings STR.
For (list It=file: : iterator. Ls. The begin (); It!=file. Ls. End (); It++)
{
STR. The Format (TEXT (" % d "), it - & gt; Id);
M_list. InsertItem (I, STR);//initialize
Int column=1;
M_list. SetItemText (I, column++, (cstrings) it - & gt; Name. C_str ());
STR. The Format (TEXT (" % d "), it - & gt; Price);
M_list. SetItemText (I, column++, STR);
STR. The Format (TEXT (" % d "), it - & gt; Num);
M_list. SetItemText (I, column++, STR);

M_list. SetItemData (I, I);//used to store the sorting keywords
i++;
}


}


In the first row, first add data clearly, don't know why no effect

CodePudding user response:

Is inserted before the data are still there

CodePudding user response:

Refer to Microsoft daoview example

CodePudding user response:

CListCtrl: : DeleteAllItems
BOOL DeleteAllItems ();

The Return Value

Nonzero if successful; Otherwise zero.

Few

Call this function to delete all the items from the list view control.

BOOL ret.=m_list DeleteAllItems ();

if(! Ret) AfxMessageBox (" DeleteAllItems Failed!" );

CodePudding user response:

DeleteAllItems just delete data items, the title bar through the CHeaderCtrl
 
CHeaderCtrl. * pHeadCtrl=mListCtrl GetHeaderCtrl ();
While (pHeadCtrl & amp; & PHeadCtrl - & gt; GetItemCount () & gt; 0)
{
PHeadCtrl - & gt; Called DeleteItem (0);
}




CodePudding user response:

Initialization time set header, column width and form control properties
Press the button to populate the data again, CListCtrl: : DeleteAllItems () can't delete the header

CodePudding user response:

Can modify headers can also use a CListCtrl: : SetColumn
  • Related