?
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,687 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 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