Forum > LCL

[SOLVED] How to move record in TDBLookupComboBox dataset - Lazarus 2

(1/2) > >>

incendio:
Hi all,

I have 2 TDBLookUpComboBox, ComboA attached to TSQLQuery Qry1, ComboB, attached to Qry2.

Qry1 & Qry2 has a same sql statement.

On each combo, ScrolllistDataSet was set to True.

On ComboA OnChange event, I have this code

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ComboB.KeyValue:= ComboA.KeyValue;
With this code, I hope that when user choose an item from ComboA, ComboB text shows the same item as ComboA, but it didn't.

Why ? Am I missing something here?

GAN:
Try ItemIndex


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ComboB.ItemIndex:= ComboA.ItemIndex;
If dosn't work, use OnEditingDone method.

incendio:
There is no ItemIndex property on TDBLookupComboBox.

kapibara:
I don't understand the endgame of this, but if both combo's use the same listsource then combo2 should show the same row as you selected in combo1 and without using any code at all. Query2 won't be used though, but since the sql statement is the same as in query1 maybe you dont need it. If you want to move to another row manually by code, you can do that by asking the query to move the row cursor, not by using the visual control. Check out Query2.Locate and Query2.Lookup.

incendio:
Both combo did not use the same listsource.

ComboA has listsource qry1 and comboB has listsource qry2.

Usually using keyvalue works, but I don't know why this time did not work.

Navigation

[0] Message Index

[#] Next page

Go to full version