Board index » delphi » Problem with TDBLookupComboBox selected item

Problem with TDBLookupComboBox selected item

Hello,

I have a problem with my TDBLookupComboBox:
When you open the TDBLCB and use the scroll  bar arrow to go up and
down WITHOUT selecting any other items (i.e. TDBLCB.Text is unchanged)
it still selects the item of the last visible row from the list...

I am going mad with this and can't find any information at all about
it..
Is it a bug from Delphi? Does anyone know how do get round this?

Please help !!!

Magali.

 

Re:Problem with TDBLookupComboBox selected item


Hello, Magali!
You wrote  on 13 Nov 2001 07:58:43 -0800:

 M> I have a problem with my TDBLookupComboBox:
 M> When you open the TDBLCB and use the scroll  bar arrow to go up and
 M> down WITHOUT selecting any other items (i.e. TDBLCB.Text is unchanged)
 M> it still selects the item of the last visible row from the list...

 M> I am going mad with this and can't find any information at all about
 M> it..
 M> Is it a bug from Delphi? Does anyone know how do get round this?

 M> Please help !!!

  It's not a bug. When you use scrollbar arrows togo up and down you moving
up and donw in your dataset. Dataset cursor's position changes so does
selected item in your TDBLookupComboBox. And there are no workaround. You
only can use TComboBox if you don't like the behavior of TDBLookupComboBox
but that's not always worth all the work you'll have to do to implement
that.

--- markus.
[ Old programmers never die. They just terminate and stay resident ]

Re:Problem with TDBLookupComboBox selected item


Thanks Markus, I was hoping it was a bug though :-(

Magali.

Re:Problem with TDBLookupComboBox selected item


Markus,

How could it not be a bug?
Ok, so going up and down moves up and down in your database.. fine,
but surely it should update the TDBLCB.Text property ??? If it did, I
wouldn't mind because then it would look obvious to the user that he
is changing the value of the other field too... but at present you
exit that list and the Text is still unchanged, whereas the TDBEdit
has changed...

Magali.

Re:Problem with TDBLookupComboBox selected item


Hello, Magali!
You wrote  on 14 Nov 2001 09:01:33 -0800:

 M> How could it not be a bug?
 M> Ok, so going up and down moves up and down in your database.. fine,
 M> but surely it should update the TDBLCB.Text property ??? If it did, I
 M> wouldn't mind because then it would look obvious to the user that he
 M> is changing the value of the other field too... but at present you
 M> exit that list and the Text is still unchanged, whereas the TDBEdit
 M> has changed...

   To change a Text property you have to select anything from the dropped
down list. Moving up and down then list doensn't mean selection. If you move
to any item in the list using  scrollbar arrows or keyboard cursor arrows
and then press Enter or click on the selected item then you'll get you Text
changed. Here is an example: Text property of TComboBox doesn't change when
you just move mouse cursor over items.

--- markus.
[ Old programmers never die. They just terminate and stay resident ]

Re:Problem with TDBLookupComboBox selected item


Markus,

Thank you for your patience Markus, I see what you mean now..
Can I change through the code the dataset cursor position back to what
the selection (Text) is ??? (without validating the data, I'd like to
have an equivalent of going up and down the list).
This way I could add it in the TBDLCB OnCloseUp procedure and that
would ensure that the TDBEdit is correct...

Please ???

Magali.

Re:Problem with TDBLookupComboBox selected item


Hello, Magali!
You wrote  on 15 Nov 2001 03:14:39 -0800:
[...sorry skipped...]
 M> Can I change through the code the dataset cursor position back to what
 M> the selection (Text) is ??? (without validating the data, I'd like to
 M> have an equivalent of going up and down the list).
 M> This way I could add it in the TBDLCB OnCloseUp procedure and that
 M> would ensure that the TDBEdit is correct...
[...sorry skipped...]

  If you just want to place a dataset cursor to a record specified in Text
propertythen you can do something like this:

procedure TForm1.DBLookupComboBox1CloseUp(Sender: TObject);
begin
   with TDBLookupComboBox(Sender) do
    DataSource.DataSet.Locate(DataField, Text, []);
end;

But notice that would work only if you haven't chosen anything in your
TDBLookupComboBox by pressing Enter or clicking mouse on an item.
Good luck.

--- markus.
[ Old programmers never die. They just terminate and stay resident ]

Re:Problem with TDBLookupComboBox selected item


Markus,

Thank you so much! it works!

Magali.

Other Threads