From: Grant on
On May 21, 2:23 pm, Grant <gra...(a)dunsmoreinfo.com> wrote:
> I have a simple problem related to my inexperiance again. I have a
> simple browser and I want to add another column with the fields
> calculated from the 2 preceeding fields. I used VirtualFieldColumn to
> create the new column but I'm stuck calculating the values for it.
> The following is the code so far.
> Thank you for any help.
>
> oColumn := oDCbBrowser1:GetOpenColumn(1)
>                 oColumn:Caption := "WEIGHT"
>                 oColumn:Width := 100
>                 oColumn:DataView := bViewStyle{Color{COLORBLACK},
> Brush{Color{COLORCYAN}},,oFont}
>                 oColumn:DataView:AlphaBlendRatio := BABR_NONE
>
>                 oColumn := oDCbBrowser1:GetOpenColumn(2)
>                 oColumn:Caption := "TONNE"+CRLF+"RATE"
>                 oColumn:Width := 100
>                 oColumn:DataView := bViewStyle{Color{COLORBLACK},
> Brush{Color{COLORGREEN}}, ,oFont}
>                 oColumn:DataView:AlphaBlendRatio := BABR_NONE
>
>                 oColumn := bVirtualFieldColumn{self:oDCbBrowser1, odbsServer, {|
> oServer|0}, #Expression}
>                 oColumn:Caption := "TOTAL"
>                 oColumn:Width := 100
>                 oColumn:DataView := bViewStyle{Color{COLORBLACK},
> Brush{Color{COLORGREEN}},,oFont}
>                 oColumn:DataView:AlphaBlendRatio := BABR_NONE
>                 self:oDCbBrowser1:OpenColumn(oColumn)

Thank you all for your comments. I did as Geoff advised and changed my
column nameing from numbers to symbol names and then used Kevin's
guideline to create the virtual column.

eg self:oDCbBrowser1:Use(odbsServer,{#SDATE, #DLOG,
#LOCATION, #SUPPLIER, #MATERIAL, #PRCAT, #TRUCK, #EQUIP, #CUSTOMER,
#WEIGHT, #HRS, #TRATE, #HRATE})
.
.
.
oColumn := oDCbBrowser1:GetOpenColumn(#WEIGHT)
oColumn:Caption := "WEIGHT"
oColumn:Width := 100
oColumn:DataView := bViewStyle{Color{COLORBLACK},
Brush{Color{COLORCYAN}},,oFont}
oColumn:DataView:AlphaBlendRatio := BABR_NONE

oColumn := oDCbBrowser1:GetOpenColumn(#HRS)
oColumn:Caption := "HOURS"
oColumn:Width := 100
oColumn:DataView := bViewStyle{Color{COLORBLACK},
Brush{Color{COLORCYAN}},,oFont}
oColumn:DataView:AlphaBlendRatio := BABR_NONE

oColumn := oDCbBrowser1:GetOpenColumn(#TRATE)
oColumn:Caption := "TONNE"+CRLF+"RATE"
oColumn:Width := 100
oColumn:DataView := bViewStyle{Color{COLORBLACK},
Brush{Color{COLORGREEN}},,oFont}
oColumn:DataView:AlphaBlendRatio := BABR_NONE

oColumn := oDCbBrowser1:GetOpenColumn(#HRATE)
oColumn:Caption := "HOUR"+CRLF+"RATE"
oColumn:Width := 100
oColumn:DataView := bViewStyle{Color{COLORBLACK},
Brush{Color{COLORGREEN}},,oFont}
oColumn:DataView:AlphaBlendRatio := BABR_NONE

oColumn := bVirtualFieldColumn{self:oDCbBrowser1, odbsServer, {|
odbsServer| (odbsServer:WEIGHT*odbsServer:TRATE)+
(odbsServer:HRS*odbsServer:HRATE)}, #Expression}
oDCbBrowser1:AddColumn(oColumn)
oDCbBrowser1:OpenColumn(oColumn)
oColumn:Caption := "TOTAL"
oColumn:Width := 100
oColumn:DataView := bViewStyle{Color{COLORBLACK},
Brush{Color{COLORGREEN}},,oFont}
oColumn:DataView:AlphaBlendRatio := BABR_NONE

This all seems to work fine and but I am still struggling with
Richard's example. I haven't got the point of StoreInfo at least in my
example because the values are addressed by their symbol names. When I
run the app I can move the columns around and the calculations still
are correct.
Thanks again for your help everyone.

From: richard.townsendrose on
Grant

when you have lots of columns, and some aren't visible, then you run
into problems

hence the two steps:
1) LOCKING the browse so coilumns cannot be moved
2) caluclating a row of values, then passing these [after
calculations] to bbrowser

remember also that you have defined columns symbols ...
our columns are
a) user definable
b) the calculations etc are user definable

i dont think that many [dot net] grid browsers support this type of
extended activity [calm down geoff]

richard