How to add Item to ListCtrl
-
Were you cheating about the effective overload of the
InsertItem
method called? :suss: Anyway: Some suggestions: (1) Changetina- wrote:
m_users.InsertColumn(0,"a",LVCFMT_CENTER,150,0); m_users.InsertColumn(1,"b",LVCFMT_CENTER,50,0); m_users.InsertColumn(2,"c",LVCFMT_CENTER,150,0); m_users.InsertColumn(3,"d",LVCFMT_CENTER,150,0);
To
m_users.InsertColumn(0,"a",LVCFMT_CENTER,150,0);
m_users.InsertColumn(1,"b",LVCFMT_CENTER,50,1);
m_users.InsertColumn(2,"c",LVCFMT_CENTER,150,2);
m_users.InsertColumn(3,"d",LVCFMT_CENTER,150,3);(2) Change
tina- wrote:
lvi.iItem = 1;
To
lvi.iItem = 0;
(3) Add, before calling
InsertItem
methodlvi.cchTextMax = _tcslen(_T("Hi"));
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]Thanx for your reply, but I made the changes & its still not working !
-
@ DavidCrow
m_users.InsertItem(0,_T("foo"));
is returning 0tina- wrote:
m_users.InsertItem(0,_T("foo")); is returning 0
Which indicates that the item is being added.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Thanx for your reply, but I made the changes & its still not working !
Try to further populate the List, for instance, add
BOOL fSuccess;
INT nItem;
fSuccess = m_users.SetItemText(0,1,_T("foo1");
fSuccess = m_users.SetItemText(0,2,_T("foo2");
fSuccess = m_users.SetItemText(0,3,_T("foo3");
nItem = m_users.InsertItem( 1, _T("boo"));
fSuccess = m_users.SetItemText(1,1,_T("boo1");
fSuccess = m_users.SetItemText(1,2,_T("boo2");
fSuccess = m_users.SetItemText(1,3,_T("boo3");Checking always, with the debugger, the return values. My resources are near to end... :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
Thanx for your reply, but I made the changes & its still not working !
Did you see my links?
-
Try to further populate the List, for instance, add
BOOL fSuccess;
INT nItem;
fSuccess = m_users.SetItemText(0,1,_T("foo1");
fSuccess = m_users.SetItemText(0,2,_T("foo2");
fSuccess = m_users.SetItemText(0,3,_T("foo3");
nItem = m_users.InsertItem( 1, _T("boo"));
fSuccess = m_users.SetItemText(1,1,_T("boo1");
fSuccess = m_users.SetItemText(1,2,_T("boo2");
fSuccess = m_users.SetItemText(1,3,_T("boo3");Checking always, with the debugger, the return values. My resources are near to end... :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]i tried to insert ur code,
> CPallini wrote: > > BOOL fSuccess; INT nItem; fSuccess = m_users.SetItemText(0,1,_T("foo1")); fSuccess = m_users.SetItemText(0,2,_T("foo2")); fSuccess = m_users.SetItemText(0,3,_T("foo3")); nItem = m_users.InsertItem( 1, _T("boo")); fSuccess = m_users.SetItemText(1,1,_T("boo1")); fSuccess = m_users.SetItemText(1,2,_T("boo2")); fSuccess = m_users.SetItemText(1,3,_T("boo3"));
but its giving exception !!! -
Did you see my links?
Hamid. wrote:
Did you see my links?
yeah, i checked ur links. the code is working very well there, but not in my project! wat shall i do ??? :confused:
-
Were you cheating about the effective overload of the
InsertItem
method called? :suss: Anyway: Some suggestions: (1) Changetina- wrote:
m_users.InsertColumn(0,"a",LVCFMT_CENTER,150,0); m_users.InsertColumn(1,"b",LVCFMT_CENTER,50,0); m_users.InsertColumn(2,"c",LVCFMT_CENTER,150,0); m_users.InsertColumn(3,"d",LVCFMT_CENTER,150,0);
To
m_users.InsertColumn(0,"a",LVCFMT_CENTER,150,0);
m_users.InsertColumn(1,"b",LVCFMT_CENTER,50,1);
m_users.InsertColumn(2,"c",LVCFMT_CENTER,150,2);
m_users.InsertColumn(3,"d",LVCFMT_CENTER,150,3);(2) Change
tina- wrote:
lvi.iItem = 1;
To
lvi.iItem = 0;
(3) Add, before calling
InsertItem
methodlvi.cchTextMax = _tcslen(_T("Hi"));
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]CPallini wrote:
Were you cheating about the effective overload of the InsertItem method called?
i didn't get u ... :confused:
-
CPallini wrote:
Were you cheating about the effective overload of the InsertItem method called?
i didn't get u ... :confused:
Oh, don't worry about. It doesn't matter. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
i tried to insert ur code,
> CPallini wrote: > > BOOL fSuccess; INT nItem; fSuccess = m_users.SetItemText(0,1,_T("foo1")); fSuccess = m_users.SetItemText(0,2,_T("foo2")); fSuccess = m_users.SetItemText(0,3,_T("foo3")); nItem = m_users.InsertItem( 1, _T("boo")); fSuccess = m_users.SetItemText(1,1,_T("boo1")); fSuccess = m_users.SetItemText(1,2,_T("boo2")); fSuccess = m_users.SetItemText(1,3,_T("boo3"));
but its giving exception !!!Then exception info maybe useful. Please post it. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
Hamid. wrote:
Did you see my links?
yeah, i checked ur links. the code is working very well there, but not in my project! wat shall i do ??? :confused:
Why they didnt work?did you get any error?
-
Then exception info maybe useful. Please post it. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]it says 0x80000003 exception occurred ...
-
I have created a ClistCtrl variable and added 4 columns to that list. Now I want to add Item to that list, I tried using InsertItem() member function, but it either doesn't work or gives an excemption. :confused: Please help me, i have alos tried using MSDN, but its all gone in vain ! :((
Thanx friends, its working now.... Thank you very much !!! :)