Solved

Use of DbGrid and a DbCheckbox

Posted on 2002-05-24
4
494 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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 give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now