Recent

Author Topic: Listview and combobox  (Read 1133 times)

jamie

  • Hero Member
  • *****
  • Posts: 3096
Re: Listview and combobox
« Reply #15 on: June 03, 2020, 10:42:07 pm »
Is there something I need to change or enable in the object inspector of the combobox?
I am not understanding your problem here. It seems you must have a miss understanding of the operation of a combobox or there is something seriously wrong in your code..

 I created a ComboBox and I put in these three items

 One
 Two
 Three

 I execute this code within a BUtton press;;
Code: Pascal  [Select][+][-]
  1.   Combobox1.ItemIndex := ComboBox1.Items.Indexof('Three');  
  2.  

And the Combobox then displays 'Three' in the caption.

 Other than that I think you have some other issue..

 Use the Debugger to examine the contents of the string to ensure its valid and does not have inserted garbage in the string.
The only true wisdom is knowing you know nothing

Paulnewyork

  • New Member
  • *
  • Posts: 44
Re: Listview and combobox
« Reply #16 on: June 04, 2020, 07:38:55 am »
  I habe now four lines, The combobox changes to Regina, but just ones by clickinging in the listview. If I click on other Data with Martin, nothing happens.

    ComboCustomer.itemindex := ComboCustomer.items.indexof('Mark');
    ComboCustomer.itemindex := ComboCustomer.items.indexof('Paul');
    ComboCustomer.itemindex := ComboCustomer.items.indexof('Martin');
    ComboCustomer.itemindex := ComboCustomer.items.indexof('Regina);

I think the Comboboxes doesn`t use the result of the SQL Query
Form2.SQLQuery3.SQL.Text := 'SELECT * from customer, sold WHERE customer.customer= sold.customer_id';   


mangakissa

  • Hero Member
  • *****
  • Posts: 1065
Re: Listview and combobox
« Reply #17 on: June 04, 2020, 09:03:27 am »
Offcourse not. You have to develop it by yourself. Take pen and paper and write in pseudo code what you really want. Now we're all guessing and I think you are using the wrong compoments to show data from database
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

Paulnewyork

  • New Member
  • *
  • Posts: 44
Re: Listview and combobox
« Reply #18 on: June 04, 2020, 04:05:19 pm »
ok. Maybe there was a missundersting.
I wanted to show data, thats right. yes thats maybe not the right component. so to show data ist not so important.

But the following is important:
I want to select an item in the combobox and then i press a button to save the item to the dataset of my mysql database.
So maybe the customer names are: paul, micha, regina, martin
and i want to change between the different names and save it (via Update table.....)

Or i want a new dataset and i select the item and add also some new information to some Edit fields.

this is my short code for INSERT conbo items to the database. Regina Micha and Martin are names which are only in Customer Table.

    ComboMarktteilnehmer.itemindex := comboMarktteilnehmer.items.indexof('Regina');
    ComboMarktteilnehmer.itemindex := comboMarktteilnehmer.items.indexof('Micha');
    ComboMarktteilnehmer.itemindex := comboMarktteilnehmer.items.indexof('Martin');
intCustomer:= ComboCustomer.ItemIndex;
    stringCustomer:= IntToStr (intCustomer);       

Form2.connectDB;
Form2.SQLQuery2.SQL.Text := 'SELECT * from customer, sold WHERE customer.customer_id= sold.customer_id';
Form2.SQLQuery2.Open;
Form2.SQLQuery1.SQL.Text := 'INSERT INTO sold (order_ID, customer_id) VALUES ('123','''+stringCustomer+''');

I think there is something wrong with the sql statements.


« Last Edit: June 04, 2020, 04:26:13 pm by Paulnewyork »

Paulnewyork

  • New Member
  • *
  • Posts: 44
Re: Listview and combobox
« Reply #19 on: June 04, 2020, 10:06:02 pm »
I have an update.

I made some if else statements and this seems to work. So now i can add new data to my tables.
I have to make some more tests later ....

mangakissa

  • Hero Member
  • *****
  • Posts: 1065
Re: Listview and combobox
« Reply #20 on: June 05, 2020, 09:27:53 am »
You need DBLookupcombox. Look at my demo. It's build on bufdataset, but can also used by tSQLQuery
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

 

TinyPortal © 2005-2018