Solved

Use of DbGrid and a DbCheckbox

Posted on 2002-05-24
4
499 Views
Last Modified: 2007-12-19
I think there is a possiblity to use dbcheckbox upon a dbgrid. Unfortunatelly the code herefore on the web is partly unusable because in D5 the OnDrawDataCel event has become obsolete (see gnomehome, uddf f.i.).

I wonder if anybody has good code to use a dbcheckbox on a dbgrid ?

Second question : some columns are read only, in the dbgrid. With tab you go to this cel, but I don't want to (is ugly...). How can I avoid the tabstop on a readonly cel ?

Third question on this grid :
I would like to "freeze" the two first columns, when scrolling to the right, as in Excel or Access...
Phil
0
Comment
Question by:PhilWillems
[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
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
nestorua earned 75 total points
ID: 7033191
HI, Phil,
As for the first question: if you mean to use dbcheckbox exactly in those cells which correspond to the boolean fields,
you don't need dbcheckbox - you can use checkbox covering the selected cell of corresponding type and hiding when the selected cell is of another type, that's all.
As for the second question: the following code skeep the column corresponding to the Field with name "SIZE"
(use OnColEnter event of your DBGrid):
procedure YourDBGridColEnter(Sender: TObject);
begin
if YourDBGrid.SelectedField.FieldName='SIZE'
 then SendMessage(YourDBGrid.Handle, WM_KEYDOWN, VK_TAB, 0);
end;
As for the third question: simply use two dbgrids instead of
one if you don't want to override the DBGrid essentially.
Sincerely,
Nestorua.
0
 

Author Comment

by:PhilWillems
ID: 7036836
Solution 2 and 3 : magnificent. Very goor solutions.

Solution 1 :
I'm not such an expert and I can't help myself.
Some code would help.

filip.willems@advalvas.be
0
 
LVL 4

Expert Comment

by:nestorua
ID: 7037390
HI, Philip,
Still try to do it by yourself, I only help you with some advice (It's much more useful than simply having ready answer).
1.Put CheckBox on the form with DBGrid on it.
2.In OnDrawColumnCell of the DBGrid check if your Field of the required type.
If so, show and move the CheckBox on the Selected Cell (changing the Left, Top, ... properties of the CheckBox and maybe use BringToFront method).
If not, hide the CheckBox.
Sincerely,
Nestorua.
0
 

Author Comment

by:PhilWillems
ID: 7038896
Still trying for several hours but only loosing my hair.
Since in this event FIELDS no longer exists I suppose I have to work with Grid.SelectedField.FieldName but I don't get any wright thing because this Field remains the same when the grid is build.(my first column).
Otherwise I have to work with fields[index] but that is not really an option, because columns can be removed, added, position changed,....
I might give up, but then my application will never be what I wanted it to be....
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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