Solved

combobox.items.AddObject

Posted on 2001-07-13
1
2,547 Views
Last Modified: 2007-12-19
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
Comment
Question by:petershaw8
1 Comment
 
LVL 9

Accepted Solution

by:
ITugay earned 100 total points
ID: 6280726
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question