Re: Help with listbox items
Hi,
using MFC you could do this:
Code:
BOOL EqualEntriesInListboxes(CDialog* pDlg, UINT idListBox1, UINT idListBox2)
{
if (pDlg)
{
CListBox* pLB1 = (CListBox*) pDlg->GetDlgItem(idListBox1);
CListBox* pLB2 = (CListBox*) pDlg->GetDlgItem(idListBox2);
if (pLB1 && pLB2)
{
pLB2->ResetContent();
int iCount = pLB1->GetCount();
if (iCount)
{
int i=0;
CString szBuffer;
for (i=0; i<iCount; i++)
{
pLB1->GetText(i, szBuffer);
pLB2->AddString(szBuffer);
}
}
return TRUE;
}
}
return FALSE;
}
The function iterates through all the entries of a listbox and adds all entries (strings) to the second listbox.
Code:
pLB2->ResetContent();
is necessary, because otherwise the strings will be added.
With regards
PA
Re: Help with listbox items
Quote:
Originally Posted by
Rgrant1993
same text on the other listbox.
~Hope i made sense.
It didn't to me. ProgramArtist gave you a way to make two listboxes contain identical strings, but it doesn't seem like that's what you're asking.
Your program would be loading up the listboxes, so why not just load what you want? I'm confused.