Click to See Complete Forum and Search --> : beginner


tufail74
August 13th, 1999, 04:55 PM
code
m_LISTCTRL.InsertColumn(0,"USER",LVCFMT_LEFT,50,-1);m_LISTCTRL.InsertColumn(1,"DESCRIPTION",LVCFMT_LEFT,100,-1);m_LISTCTRL.InsertColumn(1,"SIZE",LVCFMT_LEFT,100,-1);
//Item 1
m_LISTCTRL.InsertItem(1,"razo");m_LISTCTRL.SetItem(1,1,LVIF_TEXT,"abc.doc",0,0,0,NULL);m_LISTCTRL.SetItem(1,2,LVIF_TEXT,"145",0,0,0,NULL);
style:report
when I use this I get
USER DESCRIPTION SIZE
razo
I get the same when I changed setitem to setitemtext. Sir I think setitem/setitemtext is not working.what to do
tufail

Dmitriy
August 13th, 1999, 08:04 PM
Hi! It's me again.
So, try this

m_LISTCTRL.InsertColumn(0,"USER",LVCFMT_LEFT,50,-1);m_LISTCTRL.InsertColumn(1,"DESCRIPTION",LVCFMT_LEFT,100,-1);m_LISTCTRL.InsertColumn(1,"SIZE",LVCFMT_LEFT,100,-1);
//Item 1


m_LISTCTRL.InsertItem(1,"razo");
m_LISTCTRL.SetItemText(1,1,"abc.doc");
m_LISTCTRL.SetItemText(1,2,"145");


Dmitriy, MCSE

tufail74
August 14th, 1999, 07:00 AM
sir,
what I did is put insertcolumn statments in the onitdialog() functions and the other statments in the mouse click event of the "button". When I first time clicks the button it only displays the "razo" under the first column, but when I again click it , it displays all i.e after two clicks I get

user description size
razo

razo abc.doc 145
what is the problem.
tufail

Dmitriy
August 14th, 1999, 07:16 AM
Please show your function OnButtonClick()


Dmitriy, MCSE

Valentin Rozescu
August 14th, 1999, 07:19 AM
void CListcolDlg::OnButton1()
{
if(list.GetItemCount()==0)
{
list.InsertColumn(0,"A",LVCFMT_LEFT,50,-1);
list.InsertColumn(0,"B",LVCFMT_LEFT,50,-1);
list.InsertColumn(0,"C",LVCFMT_LEFT,50,-1);
}
list.InsertItem(1,"aa");
list.SetItemText(1,1,"aa.aa");
list.SetItemText(1,2,"11");
}

if i write this code at first push of buton in the list is write only "aa"
for every push after the first i the list will apear aa aa.aa 11
how can i do to write all strings at first push

Dmitriy
August 14th, 1999, 07:40 AM
Well. I tried it with this code:
void CListDialog::OnButtonList()
{
m_lstGroups.InsertColumn(0,_T("Newsgroups"),LVCFMT_LEFT,30);
m_lstGroups.InsertColumn(1,_T("TopId"),LVCFMT_LEFT,30);
m_lstGroups.InsertColumn(2,_T("LowId"),LVCFMT_LEFT,30);
m_lstGroups.InsertColumn(3,_T("Post"),LVCFMT_LEFT,30);
m_lstGroups.InsertItem(0,_T("first"));
m_lstGroups.SetItemText(0,1,_T("second"));
m_lstGroups.SetItemText(0,2,_T("three"));
}
It works.
So what may be the problem?
I think - 1) check your styles.
I have "single selection",
"no label wrap","show selection always",
"border", "visible", "tabstop"
2) what message does handle OnButton1() - is it simple BN_CLICKED? Or it is BN_DOUBLECLICKED?



Dmitriy, MCSE

tufail74
August 14th, 1999, 07:56 AM
Sir,
I have selected fullrowselect mode. Sir how to determine which row is selected and what are entries associated with it.
tufail

tufail74
August 14th, 1999, 07:57 AM
Sir,
I have selected fullrowselect mode. Sir how to determine which row is selected and what are entries associated with it.How to redraw the list control.
tufail

Dmitriy
August 14th, 1999, 08:52 AM
int iItem = m_LISTCTRL.GetNextItem( -1, LVNI_ALL | LVNI_SELECTED);
CString strText=m_lstGroups.GetItemText(iItem,0);

You can put these lines on your NM_CLICK or NM_DBLCLICK handler. (Create handler in ClassWizard)


Dmitriy, MCSE