[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2800
  • Last Modified:

combobox.items.AddObject

I use a stringgrid and a combobox.
for the stringgrid, I have query data set like
surname, a, b
surname is string, a, b are integer
I may add
cells[i, j] := surname;

for the combobox, I have query data set like
firstName, a, b
firstname is string, a, b are integer
items.add(firstName);

I want to add a, b into stringgrid and combobox items as objects.

So the statements above should change to
stringgrid.object[i, j]
and
combobox.items.addobject[index]

after added these object
I need to write a loop to find the mathch objects between that in combobox and that in stringgrid.

so how can I add object to stringgrid and combobox?
and how can I compare the object in the combobox and in the stringgrid?

Peter

0
petershaw8
Asked:
petershaw8
1 Solution
 
ITugayCommented:
Hi peter,

it is depend from how big your values A and B. If it is in [-32768..32768] then you can keep both values as integer. Integer is 32 bit length (the same as pointer), first 16 bits as A value, second is B.

var
  P: pointer;
begin
  P := pointer( A shl 16 or B);
....
  List.AddObject('string', P);

you can search:
var
  I: Integer;
begin
  // A - value
  for I := 0 to List.Count-1 do
    if Integer(List.Objects[I]) and $FFFF0000 shr 16 = SearchValueA then // do something
  // B- value
    if Integer(List.Objects[I]) and $FFFF = SearchValueB then // do something

------
Igor.
 




0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now