about picklist

Is there a way to prevent a user from typing in a value directly and forcing him to select an option from the picklist?

I want the same functionality for my DBGrid.Columns[i] as I can get in a ComboBox by setting the Style to csDropDownList.
zzlingAsked:
Who is Participating?
 
GreymanConnect With a Mentor Commented:
Hopefully, your picklist is stored in a dataset somewhere.  (A ClientDataSet is ideal for this sort of thing.)  Assuming that it is, the answer is to:

Double-click the dataset that is being displayed in the DBGrid to get the fields editor.

Right-click it and Add Fields.  Add all of the fields that it suggests.

Right-click again and select New Field.
Add a lookup field - it has properties that are very similar to a DBLookupCombo.

Double-click your DBGrid to get the columns editor, and make sure that the column subject to lookup is not there, and that the lookup field is.

F9 :)
0
 
intheCommented:
maybe you could do:

procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
key := #0;
end;
0
 
isasoriCommented:
If you need to prevent a user from typing in a value directly, then i have
good answer.
0
All Courses

From novice to tech pro — start learning today.