Board index » delphi » Selected Text in DBGrid

Selected Text in DBGrid

Is there any way of determining what text the user has highlighted in a
DBGrid? There is a SelectedField property but no SelText property like there
is for TCustomEdit. Any ideas?
 

Re:Selected Text in DBGrid


Quote
>Simon Woodman wrote:

>Is there any way of determining what text the user has highlighted in >a DBGrid? There is a SelectedField property but no SelText property >like there is for TCustomEdit. Any ideas?

Use one of the properties of SelectedField like AsString or Text.
________
Andreas
Delphi 5.01 Pro, NT4.0 Sp5
Direct replies mailto:p...@augsburg.netsurf.de

Re:Selected Text in DBGrid


AsString or Text gives the entire contentes of the field. What I am after is
the portion of the field that the user has highlighted with the cursor.

Thanks
Simon

Quote
"Andreas Pawlik" <no~j...@augsburg.netsurf.de> wrote in message

news:3A3FAB69.FC43D965@augsburg.netsurf.de...
Quote
> >Simon Woodman wrote:

> >Is there any way of determining what text the user has highlighted in >a

DBGrid? There is a SelectedField property but no SelText property >like
there is for TCustomEdit. Any ideas?
Quote

> Use one of the properties of SelectedField like AsString or Text.
> ________
> Andreas
> Delphi 5.01 Pro, NT4.0 Sp5
> Direct replies mailto:p...@augsburg.netsurf.de

Re:Selected Text in DBGrid


User selects/edits text in child control called InplaceEditor, not the grid
itself. If you want to access it, you either enumerate all controls of
DBGrid or write a descendent of DBGrid that exposes InplaceEditor.
InplaceEditor is TCustomEdit descendent.
--
----------------------
Regards
Robert Cerny
Remove both qwe when replying
email: robert.qwe.ce...@neosys.xrs.qwe.si

No questions via email, unless explicitly invited.

Quote
Simon Woodman wrote in message <91mi2b$...@bornews.inprise.com>...
>Is there any way of determining what text the user has highlighted in a
>DBGrid? There is a SelectedField property but no SelText property like
there
>is for TCustomEdit. Any ideas?

Re:Selected Text in DBGrid


Quote
>Simon Woodman wrote:

>AsString or Text gives the entire contentes of the field. What I am >after is the portion of the field that the user has highlighted with >the cursor.

Sorry, might have read your question more carefully.
I think you will have to access the InplaceEditor then. Since this is
protected in CustomGrid, you need a cracker class like

  type
    TCrackGrid = class(TDBGrid);
  .
  .
  s := TCrackGrid(DBGrid1).InplaceEditor.SelText;
________
Andreas
Delphi 5.01 Pro, NT4.0 Sp5
Direct replies mailto:p...@augsburg.netsurf.de

Re:Selected Text in DBGrid


Thanks, exactly what I needed.

Quote
"Andreas Pawlik" <no~j...@augsburg.netsurf.de> wrote in message

news:3A40DE28.32EAA3CB@augsburg.netsurf.de...
Quote
> >Simon Woodman wrote:

> >AsString or Text gives the entire contentes of the field. What I am
>after is the portion of the field that the user has highlighted with >the
cursor.

> Sorry, might have read your question more carefully.
> I think you will have to access the InplaceEditor then. Since this is
> protected in CustomGrid, you need a cracker class like

>   type
>     TCrackGrid = class(TDBGrid);
>   .
>   .
>   s := TCrackGrid(DBGrid1).InplaceEditor.SelText;
> ________
> Andreas
> Delphi 5.01 Pro, NT4.0 Sp5
> Direct replies mailto:p...@augsburg.netsurf.de

Other Threads