Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

Skipping TDBGrid cells on condition

Hi there,

I have a TDBGrid that connects to a table in a database.  The cells in the grid are editable and I have a column in this grid that is called 'Weight Units' which connects to the underlying field in the database and another column before it in the grid called Quantity.

I also have a drop-down TDBLookUpComboBox that looks-up a table in the DB and displays all the weight units e.g. KG, lb, Tons etc.

What I want is that if I enter a quantity in the cell under the Quantity column then the TDBLookUpComboBox will pop-up on the OnColExit event so that the user can choose a quantity.  However, if the user enters '0' in the Quantity column then I don't want the TDBLookUpComboBox to pop up and simply skip to the next line in the grid for input.  I have associated the TDBLookUpComboBox to the grid column 'Weight Units' and set both it and the datasource to be readonly if it detects that the quantity field is 0.  I have also set the tabstop on the TDBLookUpComboBox to be false when this is the case.

However, I am still finding that the cursor stops on the TDBLookUpComboBox in the 'Weight Units' column even when the quantity field is 0.

Can anyone help or provide tips?

Many thanks
-ROD
0
rodski
Asked:
rodski
1 Solution
 
da-vinciCommented:
Hello rodski

I tried your question with this procedure:

procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
    if (DBGrid1.Fields[0].AsInteger <> 0) and (DBGrid1.SelectedIndex=0) then
        DBLookupComboBox1.DropDown;
end;

Where field 0 is the 'quantity' field and field 1 is the 'weight units' field. I didn't set the readonly to True or anything else.

In my case the cursor didnt stop at the weight units column.
Is this what you mean ?
0
 
CleanupPingCommented:
rodski:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
kacorretiredCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to accept da-vinci's answer
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Some days and here is the Christmas Time. I wish good luck and good health for you all and for your loved ones

kacor
EE Cleanup Volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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