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

x
?
Solved

How to select (highlight and receive focus) entire text of selected cell in Delphi DBGrid?

Posted on 2010-01-11
5
Medium Priority
?
1,775 Views
Last Modified: 2013-11-23
Hello,

I have a simple DBGrid, DBNavigator, and an 'Edit' button which simplly 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 then DBNavigator.BtnClick(nbEdit) the whole cell is highlighted.

how can I select the entire text of a selected cell (or alternatively simulate 2 mouse clicks programatically)

Thanks in advance for all efforts.
What-I-Want.JPG
Not-What-I-Want.JPG
0
Comment
Question by:samenglish
5 Comments
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 1000 total points
ID: 26291288
Use DBGid.SelectedGrid.FocusControl TDBGrid procedure

begin
DbNavigator1.BtnClick(nbedit);
dbgrid1.SelectedField.FocusControl;
end;
0
 
LVL 38

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 800 total points
ID: 26291497
have you tried to set the option dgAlwaysShowEditor in the options of the DBGrid to true ?
0
 
LVL 2

Assisted Solution

by:gurkal
gurkal earned 200 total points
ID: 26291594
I think that both solutions are right. Also you can access DbGrid Editor controls like this

type
  THackTDbGrid = class(TDbGrid);

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  Edit: TCustomEdit;
begin
     Edit:=THackTDbGrid(DbGrid1).InplaceEditor;
     ShowMessage(Edit.SelText);
end;
0
 
LVL 3

Expert Comment

by:Freddy1990
ID: 26292770
You could check out NextGrid, it's a fairly cheap grid component compared to other payed components. I believe it also has a DBGrid version. http://www.bergsoft.net/component/next-grid/overview.htm
It has a lot of fieldtypes, including editable fields. It alos allows you to make "slides". The control is not as advanced maybe as DevExpress' grid components, but it's easy to use, has a lot of features and might be just what you need. there's a demo you can download. I'm pretty satisfied with the component anyway, with a lot of BergSoft's components actually.
0
 
LVL 7

Author Closing Comment

by:samenglish
ID: 31675934
Ferruccio68 and Geert Gruwez: real experts - thank you.
gurkal: thanks for the extra useful info, I appreciate it.
Freddy1990: honourable mention, I'll keep that in mind.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question