oracle - Get current cell value in DBGrid -
in delphi application, use lookup fields, in unusual way. actually, wanna update field in underlying data set, if in same table.
existing guides tell there no problem, join table , voila... envy if succeeded task such simple solution. not. btw think i'm getting close reach goal. have 1 question left: how hell can value just entered dbgrid cell?
i tried dbgrid[fieldname].editvalue
, .displaytext
, show same value field.value
, doesn't change after exiting column, because lookup field. sender.newvalue
null. i'm using function update lookup table:
procedure tkdgridform.lookupfieldchange(sender: tfield); begin if not assigned(sender) exit; sender.onchange := nil; if not assigned(sender.lookupdataset) exit; if sender.lookupdataset.locate(sender.lookupkeyfields, sender.dataset[sender.keyfields], []) sender.lookupdataset.edit else sender.lookupdataset.append; // how value entered? sender.value := kdgrid3[sender.fieldname].displaytext; sender.lookupdataset.fieldvalues[sender.lookupresultfield] := sender.value; sender.lookupdataset.post; sender.onchange := lookupfieldchange; end;
here sql used before ended lookup fields:
select det.*, od1.t_eq t_shablon_eq, od1.t_nv t_shablon_nv, od1.t_prim t_shablon_prim, od2.t_eq t_pravka_eq, od2.t_nv t_pravka_nv, od2.t_prim t_pravka_prim, od3.t_eq t_valcov_eq, od3.t_nv t_valcov_nv, od3.t_prim t_valcov_prim, od4.t_eq t_rezka2_eq, od4.t_nv t_rezka2_nv, od4.t_prim t_rezka2_prim cmknew.details det left join cmknew.operdetails od1 on det.nrec = od1.cdetail , 81 = od1.coper left join cmknew.operdetails od2 on det.nrec = od2.cdetail , 82 = od2.coper left join cmknew.operdetails od3 on det.nrec = od3.cdetail , 83 = od3.coper left join cmknew.operdetails od4 on det.nrec = od4.cdetail , 84 = od4.coper det.ckd=:ckd order det.nrec
hope explain task clearer. if wanna mcve, can extend this, though think it's not essential.
my database oracle, connected through ado. i'd solution simple possible.
i assume you're talking standard tdbgrid , you're asking how text displayed in cell of grid when type it, before grid's dataset updated. @ point, current row indicator in lh column have changed default right-pointing triangle i-beam
if so, snippet below shows how text value. point is, in condition i've described, what's in cell hasn't yet been posted underlying dataset field. happens when start editing, inplaceeditor (tcustommaskedit descendant) dynamically created, , it's holds text value being edited.
add ttimer , tmemo form , run code below see mean.
type tmygrid = class(tdbgrid); procedure tmyform.timer1timer(sender: tobject); var s : string; grid : tmygrid; begin grid := tmygrid(dbgrid1); if grid.inplaceeditor <> nil s := grid.inplaceeditor.text else s := inttostr(grid.col) + ':' + inttostr(grid.row); grid.invalidate; memo1.lines.insert(0, s); end;
Comments
Post a Comment