i have a dbgrid with two columns basically when one of the column value is 'y' i want to translate that value in the in that specific column to 'yes' etc how would i acheive something like this?
You will use a "Calculated Field". How this is done depends on the data set connected to the grid. If it's a query of some sort, you'll probably need to make the translation in the query itself - I know this is true for TQuery, but I haven't worked with the ADO datasets.
If it's a table (i.e., TTable or similar) you would set up persistent fields (double-click on the table, right-click on the new form and select "Add All Fields"). You then add a new field with a field type of Calculated - in your case it would be a string field with a size of 3. Then, in the OnCalcFields event handler, you would put code similar to the following:
Code:
If Table1.FieldByName('MyField').AsString = 'y' then
Table1.FieldByName('MyCalcField').AsString := 'Yes'
else if Table1.FieldByName('MyField').AsString = 'n' then
Table1.FieldByName('MyCalcField').AsString := 'No';
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.