database - What was picked within a columns.picklist? -
i wasted bit of time trying work out figured simple.
i've got database multiple tables (mysql). 1 table containing "components" , containing "products". products built using components, example; product abc might made of 3 x screws, 4 x bolts, 1 kilogram of fresh air... etc! making sense far?
the components displayed in dbgrid. if user makes mistake , wants add "component" "product" picklist appears listing components (from different table) them select from.
now, here's problem! when selected column[i].picklist (this part of dbgrid) how know selected. thought there event fired, there doesn't seem be.
i need know item selected can retrieve appropriate description next field.
there 3 fields, component, description, quantity. component , quantity can edited user.
i hope i'm making sense here.
here code i'm using (as messy is);
procedure tform1.completepolessourcestatechange(sender: tobject); var loop: integer; tmp: string; begin case completepolessource.state of dsinsert: begin compvals.clear; // tstringlist created elsewhere compvals.delimiter := '|'; compvals.quotechar := '"'; polecomponentsgrid.columns[0].readonly := false; // readonly when not in dsinsert polecomponentsgrid.columns[0].picklist.clear; // clear other crap { add parts name / value list (code / description) can later description without looking in other table. } loop := 1 componentstable.recordcount // code other table begin componentstable.recno := loop; tmp := componentstable.fieldbyname('code').asstring + '=' + componentstable.fieldbyname('item').asstring; compvals.add(tmp); polecomponentsgrid.columns.items[0].picklist.add(tmp); end; polecomponentsgrid.columns.items[0].readonly := true; end; end; end;
this show data of selected rows of dbgrid
procedure tfrmprincipal.btnshowselectedrowsclick(sender: tobject); var i: integer; aux: string; begin := 0 dbgrid1.selectedrows.count - 1 begin clientdataset1.gotobookmark(pointer(dbgrid1.selectedrows.items[i])); aux := aux + inttostr(clientdataset1.recno) + ' - ' + clientdataset1.fieldbyname('customer').asstring + #13; end; showmessage(‘selected rows: ‘ + #13 + aux); end;
Comments
Post a Comment