Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How can I prevent editor in a TDBgrid


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 14 - Last Post: Feb 29, 2016 9:40 AM Last Post By: Peter Below
Papas Jim

Posts: 90
Registered: 10/13/00
How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 27, 2016 2:54 PM
Hi,
I want to change the value of a field shown in a TDBgrid using my own edit control, not the grid's one.
How can i force the grid's editor not to shown. please ?
The grid must be in edit mode.
thanks in advance
Linden ROTH

Posts: 467
Registered: 11/3/11
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 27, 2016 6:05 PM   in response to: Papas Jim in response to: Papas Jim
Papas Jim wrote:
Hi,
I want to change the value of a field shown in a TDBgrid using my own edit control, not the grid's one.
How can i force the grid's editor not to shown. please ?
The grid must be in edit mode.
thanks in advance

This begs the question ... why must the grid be in edit mode ?

--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"
Papas Jim

Posts: 90
Registered: 10/13/00
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2016 4:17 AM   in response to: Linden ROTH in response to: Linden ROTH

This begs the question ... why must the grid be in edit mode ?

--
thanks Linden for your reply

sorry, my fault.
It must not be in edit mode, but even i check the readonly property, the editor shows up himself when i click on a selected cell.
How can avoid this, please ?
Roy Lambert

Posts: 1,063
Registered: 8/7/01
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2016 4:46 AM   in response to: Papas Jim in response to: Papas Jim
Papas

You can set the dbgrid to readonly which should stop any editor coming up, but to replace it with your own editor is more difficult (I know I've done it in my own subclassed dbgrid).

What are you actually trying to achieve and why?


Roy Lambert

Papas Jim

Posts: 90
Registered: 10/13/00
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2016 5:49 AM   in response to: Roy Lambert in response to: Roy Lambert
You can set the dbgrid to readonly which should stop any editor coming up, but to replace it with your own editor is more difficult (I know I've done it in my own subclassed dbgrid).

What are you actually trying to achieve and why?

thanks Roy for your reply

Setting DBgrid to readonly doesn't stop editor comming up if i click on a already selected cell.
Only avoids to change the field's value.
I want to replace the default editor with a custom one that can act as an inline calculator expanding itself as needed.
This custom editor should be shown only on keyDown event, not with onclick event.
Krzysztof Szyszka

Posts: 78
Registered: 3/4/04
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2016 6:17 AM   in response to: Papas Jim in response to: Papas Jim
You can set the dbgrid to readonly which should stop any editor coming up, but to replace it
with your own editor is more difficult (I know I've done it in my own subclassed dbgrid).

What are you actually trying to achieve and why?

thanks Roy for your reply

Setting DBgrid to readonly doesn't stop editor comming up if i click on a already selected cell.
Only avoids to change the field's value.
I want to replace the default editor with a custom one that can act as an inline calculator
expanding itself as needed.
This custom editor should be shown only on keyDown event, not with onclick event.

You should override CreateEditor method in your own TMyDBGrid component and implement this
calculator in your own TMyDBGridInplaceEdit class.
Only then your editor will act in accordance with all the editing functions in the TDBGrid
component.

--
pozdrowienia
Krzysztof Szyszka, X-Files Software
Developer of X-DBGrid Component
Embarcadero Technology Partner
http://www.x-files.pl/
Join to "Delphi X-DBGrid Component Community"
https://plus.google.com/#communities/100842098152269100547
Roy Lambert

Posts: 1,063
Registered: 8/7/01
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2016 7:15 AM   in response to: Papas Jim in response to: Papas Jim
Papas

You have two options:

1. buy a nice advanced grid component that will allow you to do this
2. find a nice brick wall to headbut and be prepared to pull all your hair out.

Krzysztof makes it sound very simple - it isn't - his grid does a very good job

Roy Lambert

Papas Jim

Posts: 90
Registered: 10/13/00
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2016 8:21 AM   in response to: Roy Lambert in response to: Roy Lambert

Krzysztof makes it sound very simple - it isn't - his grid does a very good job
I already can invoke my custom editor when i press a key. I only need a way to vanish the Grid's inplace editor.
Roy Lambert

Posts: 1,063
Registered: 8/7/01
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 29, 2016 12:09 AM   in response to: Papas Jim in response to: Papas Jim
Papas

Essentially its as Krzysztof says - you need to override CreateEditor.

Google "delphi stringgrid inplace editor" to find a start point.

Roy Lambert

Roy Lambert

Posts: 1,063
Registered: 8/7/01
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 29, 2016 12:39 AM   in response to: Papas Jim in response to: Papas Jim
Papas

If you think it will help send me an email and I'll send you the code of my subclassed version of Mike Skolnik's subclassed dbgrid. It won't compile at your end because there'll be a slew of components missing but at least it'll show you where I set things.

Roy Lambert

Krzysztof Szyszka

Posts: 78
Registered: 3/4/04
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2016 10:25 AM   in response to: Roy Lambert in response to: Roy Lambert
Krzysztof makes it sound very simple - it isn't - his grid does a very good job

Roy, I did not write, it would be simple, easy and fun, but it is possible and correct.

--
pozdrowienia
Krzysztof Szyszka, X-Files Software
Developer of X-DBGrid Component
Embarcadero Technology Partner
http://www.x-files.pl/
Join to "Delphi X-DBGrid Component Community"
https://plus.google.com/#communities/100842098152269100547
Roy Lambert

Posts: 1,063
Registered: 8/7/01
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 29, 2016 12:04 AM   in response to: Krzysztof Szyszka in response to: Krzysztof Szyszka
Krzysztof

Roy, I did not write, it would be simple, easy and fun, but it is possible and correct.

Well, for a certain value of fun ......

<G>

Roy
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2016 6:33 AM   in response to: Papas Jim in response to: Papas Jim
Papas Jim wrote:


This begs the question ... why must the grid be in edit mode ?

--
thanks Linden for your reply

sorry, my fault.
It must not be in edit mode, but even i check the readonly property,
the editor shows up himself when i click on a selected cell. How can
avoid this, please ?

You have to set the datasource's autoedit property to false, if memory
serves. Otherwise the dataset goes into edit mode automatically when
the user clicks a cell.

--
Peter Below
TeamB
Papas Jim

Posts: 90
Registered: 10/13/00
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2016 6:55 AM   in response to: Peter Below in response to: Peter Below
You have to set the datasource's autoedit property to false, if memory
serves. Otherwise the dataset goes into edit mode automatically when
the user clicks a cell.
thanks Peter for your reply
Even setting datasource's autoedit property to FALSE doesn't stop editor. Only needs one more click.
I want it never shown up.
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: How can I prevent editor in a TDBgrid  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 29, 2016 9:40 AM   in response to: Papas Jim in response to: Papas Jim
Papas Jim wrote:

You have to set the datasource's autoedit property to false, if
memory serves. Otherwise the dataset goes into edit mode
automatically when the user clicks a cell.
thanks Peter for your reply
Even setting datasource's autoedit property to FALSE doesn't stop
editor. Only needs one more click. I want it never shown up.

Then you have to set the dataset itself to readonly.

--
Peter Below
TeamB
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02