Go Premium for a chance to win a PS4. Enter to Win

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

Problems with TComboBox !!!!

How can I load on the TComboBox component one colum of a TDBGrid (I load one Table1) that I create from a DataBase (Access 97).
I only could load the first line of my Table1 with this:

cant := Form1.Table1.RecordCount;
  for  i := 0 to cant do
    Form3.List.Items.Insert(i, Form1.Table1);

I need to load each line of one colum.  Thanks.
0
matuf
Asked:
matuf
1 Solution
 
Mohammed NasmanSoftware DeveloperCommented:
Hello

  change ur code as following ,you are adding only the first record, so you need to move to the next one


cant := Form1.Table1.RecordCount -1;
 for  i := 0 to cant do
  begin
   Form3.List.Items.Insert(i, Form1.Table1);
   Form1.Table1.Next;
  end



0
 
ITugayCommented:
Hi matuf,

something like this:

Table1.DisableControls;
Table1.First;
while not Table1.EOF do
begin
  ListBox1.Items.Add(Table1.Fields[3].AsString);
  Table1.Next;
end;
Table1.EnableControls;

0
 
kretzschmarCommented:
recordcount is not allways properly set,
depending on the database

better would be
table1.first;
while not table1.eof do
begin
  Form3.List.Items.add(table1.fieldbyname('fieldwhateverneeded').asstring;
  table1.next;
end;

meikl ;-)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ITugayCommented:
:-)
0
 
matufAuthor Commented:
0
 
kretzschmarCommented:
hu,
igor didn't see your comment before now,
sorry to get a grade, which should you have get

but anyway

matuf, thanks for the points :-)
glad to be of service
good luck again

meikl ;-)
0
 
kretzschmarCommented:
igor, its only a c-grade :-(
0
 
ITugayCommented:
really? I miss nothing :-)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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