April 26, 2024, 01:43:30 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Copy a whole line in a Listview

Started by Brian, May 01, 2013, 02:02:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

Hi,

I need to  copy a whole line (all columns) from a listview, and write it intact to a file

I'm OK with the file writing, but is there a way to copy the whole line of a listview?

Brian

billhsln

CASE @NMCLICK
lvi=*<NMLISTVIEW>@LPARAM.iItem
CONTROLCMD(d1,D1_L1,@LVGETTEXT,lvi,0,RecNo$)
CONTROLCMD(d1,D1_L1,@LVGETTEXT,lvi,1,baseset)
CONTROLCMD(d1,D1_L1,@LVGETTEXT,lvi,2,cardset)
CONTROLCMD(d1,D1_L1,@LVGETTEXT,lvi,3,hp)
CONTROLCMD(d1,D1_L1,@LVGETTEXT,lvi,4,rarity)
CONTROLCMD(d1,D1_L1,@LVGETTEXT,lvi,5,ctype)
CONTROLCMD(d1,D1_L1,@LVGETTEXT,lvi,6,abbrev)
CONTROLCMD(d1,D1_L1,@LVGETTEXT,lvi,7,setno)
CONTROLCMD(d1,D1_L1,@LVGETTEXT,lvi,8,fullname)
orec = RecNo$ + baseset + cardset + hp + rarity + ctype + abbrev + setno + fullname
Write (ofile,orec)


If I were going to pull the entire listview and sent it to a file, I would do the above or something close to it.

Bill
When all else fails, get a bigger hammer.

LarryMc

The above example doesn't take into account a delimiter separating the field data

I would put it in a subroutine like this(it does the same thing and adds a delimiter.)

CASE @NMCLICK
   lvi=*<NMLISTVIEW>@LPARAM.iItem
   Write (ofile,get_list_line(d1,D1_L1, lvi, 9))



sub get_list_line(window win, int id, int ln, int cols),string
   string text$,temp
   int x

   for x=0 to cols-2
      CONTROLCMD(win, id, @LVGETTEXT, ln, x, temp)
      text$ += temp+","
   next x
   CONTROLCMD(win, id, @LVGETTEXT, ln, x, temp)
   text$ += temp
   return text$
endsub

I don't know what the max width of data in each colum is; so you may need to adjust and use ISTRINGS
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Brian

Thanks, Chaps!

The length of a whole line is never more than 260 chars. I can work with some of that code easy enough

I just want it to loop through the whole listview, line by line, and write the data out. Thing is, depending on
what a particular column contains, the line either goes to File A or to File B. I'm not bothered about grabbing
the data with a mouse click

Bedtime here now!

Brian