Post by metro on Mar 22, 2019 6:21:04 GMT -5
I am re-writing a program I have that downloads stock market data and have realized handling a 1000 or more records with a grid
could be problematic. (for me at least)
I could of course just page in say a hundred rows at a time but I would prefer to load a complete set.
Loading and displaying is easy but if I want to edit row (say...765) it may get messy.
I have come up with one solution (below) . this gives me the data of one row I can then edit individual fields from there.
Can I have some suggestions as to how others may tackle the problem....
hint: click on "ACD"
thanks for the feed back
sep$=chr$(34)+chr$(44)+chr$(34)
Cn$="Edit , Opt Code ,Exp Date,Call.Put , Days , Strike , Bid , Offer , Last, volume , Margin , Intrinsic , Time"
Cn$=strRep$(Cn$,",",sep$)
colNames$=chr$(34)+Cn$+chr$(34)
WindowWidth=900
WindowHeight=650
UpperLeftX=(DisplayWidth-WindowWidth)/2
UpperLeftY=(DisplayHeight-WindowHeight)/2
Rownames$=""
for n=1 to 101
Rownames$=Rownames$+","+str$(n)
next
lenR=len(Rownames$)
Rownames$=right$(Rownames$,lenR-1)
dim a$(4, 100)
grid #w.grid, a$(), [clicked], 10, 10, 800, 300
for x = 0 to 4
for y = 0 to 100
a$(x,y) = "c"+str$(x)+" r"+str$(y)
a$(0,y)="ACD"
next y
next x
texteditor #w.te1,75,330,800,300
open "Grid test" for window as #w'
cn$ = eval$("#w.grid columnnames("+colNames$+")")
#w.grid columnwidths(60)
a = eval("#w.grid rownames("+Rownames$+")") 'label the rows
#w.grid rowlabelwidth(60)
wait
[clicked]
'#w.te1 cls(1) why not?
#w.te1 "!cls"
#w.te1 "clicked: "; #w.grid cellxy$()
r$=#w.grid cellxy$()
if left$(r$,1)="1" then
#w.te1 "all Values"
lenr=len(r$)
#w.te1 r$;" r$";" length is ";str$(lenr)
select case lenr
case 3
rw$= right$(r$,2)
case 4
rw$= right$(r$,2)
case 5
rw$=right$(r$,3)
case else
rw$=right$(r$,4)
end select
y=val(rw$)
for x= 1 to 4
#w.grid selectxy(x+1,y)
#w.te1 #w.grid value$()
next x
end if
wait
function strRep$(str$,rep$,with$)
ln = len(rep$)
ln1 = ln - 1
i = 1
while i <= len(str$)
if mid$(str$,i,ln) = rep$ then
strRep$ = strRep$ + with$
i = i + ln1
else
strRep$ = strRep$ + mid$(str$,i,1)
end if
i = i + 1
wend
end function