Hi,
I have a listview. I know how many rows there are, and I know how many columns
there are
What I want to do is copy each full line into a new line. So Line 1 would be copied, and
make a new Line 2; the original Line 2 would then become Line 3, and that is copied,
and make a new Line 4, and so on
Can't get my head round this one. Any ideas, please?
Brian
			
			
			
				What are you going to do with line one(which is the same as line two) after the copying is done?
Just guessing here:
If you are just wanting to push everything down so you can add to the list at he top
all you have to do is insert @ pos=0
QuoteCONTROLCMD window | dialog, ID, @LVINSERTITEM, position, item$
Use this statement to insert an item into the list view control.
Position is the zero-based index of the item to insert.
Item$ is the text of the item
If for some reason you want line 1 and 2 to be the same then still use insert @ pos=0 and then copy the contents of line 2 into line 1
Regardless of what you ultimately want to do you can not be using either of the sort flags when you create the listview. If you are using one of them the listview will automatically position the inserted line whereever it calculates it belongs.
LarryMc
			
				Hi, Larry,
Fixed that little problem. Now on to the next!
Just wondered if it was possible, when you had a listview opened, if there
was a command to check how many columns there were. There's obviously
one to check how many lines there are, just wondered about columns
Brian
			
			
			
				CONST LVM_FIRST = 0x1000
CONST LVM_SETEXTENDEDLISTVIEWSTYLE = (LVM_FIRST + 54)
CONST LVS_EX_FULLROWSELECT = 0x20
CONST LVS_EX_GRIDLINES = 1
CONST LVS_EX_FLATSB = 0x100
CONST LVS_EX_LABELTIP = 0x4000
type LVCOLUMN
  UINT mask 
  int fmt 
  int cx 
  string pszText 
  int cchTextMax 
  int iSubItem 
  int iOrder
  int iImage
endtype 
CONST LVCF_ORDER = &H20
CONST LVM_FIRST = &H1000
CONST LVM_GETCOLUMNA = (LVM_FIRST + 25)
def d1 as Dialog
LVCOLUMN lvc
CREATEDIALOG d1,0,0,295,168,0x80C80080,0,"Column Count Demo",&handler
CONTROL d1,@LISTVIEW,"",27,10,240,110,@LVSREPORT|@BORDER|@LVSSHOWSELALWAYS,100
CONTROL d1,@button,"Col Count",27,125,240,20,0,300
CONTROL d1,@STATIC,"",27,150,240,20,0,200
'show the dialog and wait for it to close
domodal d1
'end program
end
SUB handler
select @MESSAGE
	case @IDINITDIALOG
		centerwindow d1
		'insert columns and some items
		'after an item is inserted we use @LVSETTEXT to
		'change the subitems text
		CONTROLCMD d1,100,@LVINSERTCOLUMN,0,"Column1"
		CONTROLCMD d1,100,@LVINSERTCOLUMN,1,"Column2"
		CONTROLCMD d1,100,@LVINSERTCOLUMN,2,"Column3"
		CONTROLCMD d1,100,@LVINSERTCOLUMN,3,"Column4"
		'the first columns item and sub items
		CONTROLCMD d1,100,@LVINSERTITEM,0,"Item 1"
		CONTROLCMD d1,100,@LVSETTEXT,0,1,"Sub 1"
		CONTROLCMD d1,100,@LVSETTEXT,0,2,"Sub 2"
		'the second column
		CONTROLCMD d1,100,@LVINSERTITEM,1,"Item 2"
		CONTROLCMD d1,100,@LVSETTEXT,1,1,"Sub 1"
		'the third column
		CONTROLCMD d1,100,@LVINSERTITEM,2,"Item 3"
		'change some of the listview extended styles
		SENDMESSAGE d1,LVM_SETEXTENDEDLISTVIEWSTYLE,0,LVS_EX_FLATSB|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_LABELTIP,100
	case @IDCONTROL
		SELECT @CONTROLID
			CASE 300
				IF @NOTIFYCODE = 0 
					blocked = GetState(d1,300)
					lvc.mask=LVCF_ORDER
					x=-1
					do
						x++
					until sendmessage (d1,LVM_GETCOLUMNA,x,lvc,100 )=0
					setcontroltext d1 ,200, "LV has"+str$(x)+" columns"
				endif
		ENDSELECT
endselect
return
ENDSUB
LarryMc
			
			
			
				Many thanks, Larry,
Fitted and working, just as I wanted it to
Brian