Solved

Use of DbGrid and a DbCheckbox

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

11 Experts available now in Live!

Get 1:1 Help Now