0

I have a simple DBGrid, DBNavigator, and an 'Edit' Button which simply calls

DBNavigator.BtnClick(nbEdit);

When the user clicks 'Edit', I want the text in the selected cell (just the text - not the whole cell) to be highlighted - as if ready to be overwritten; whereas when I do

DBGid.SetFocus; 
DBNavigator.BtnClick(nbEdit);

the whole cell is highlighted.

How can I select the entire text of a selected cell?

3 Answers 3

2

Set 'Options - dgAlwaysShowEditor' to true.

2
  • Yep, that achieves the objective. Thanks.
    – Sam
    Jan 12, 2010 at 22:48
  • Can you please select my answer than (clicking the number in front of the anwswer). Thx
    – Edelcom
    Jan 13, 2010 at 8:53
1
DBGrid.SelectedField.FocusControl;
0

This works with me when I want to highlight the field text in grid to point to specific field when adding new item in grid.

grd->SelectedIndex = 1; // then field index
grd->EditMode = true;  
((TFloatField*)grd->SelectedIndex)->EditFormat = "";   // remove the format 
((TFloatField*)grd->SelectedIndex)->EditFormat = "#.00";   // set back editformat
grd->DataSource->DataSet->Edit();   // set dataset to edit mode 

The trick is to change the EditFormat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.