I'm using Delphi 6 Enterprise Upate Pack 2. Now I have the following
problem:
In a database table there's a numeric field, which can only have the values
0 and 1 (0 stands for False and 1 for True).
Now I connect this table to a DBGrid and the persistent field to a column.
The user should be able to set these values for this field, but not numeric
0 or 1! He should be able to do something like with a checkbox, not checked
is False (=0) and checked is True (=1).
Any ideas (also a non DBGrid solution)?
PS: I don't want to use an extra component for handling this simple stuff.
Regards
Stephan Schneider
>In a database table there's a numeric field, which can only have the values
>0 and 1 (0 stands for False and 1 for True).
That field is crying to become a boolean.
>Now I connect this table to a DBGrid and the persistent field to a column.
>The user should be able to set these values for this field, but not numeric
>0 or 1! He should be able to do something like with a checkbox, not checked
>is False (=0) and checked is True (=1).
And this a picklist with True and False (some grids do show a
checkbox, but my solution is simpler, though not so fancy). In the
CellClick event for the DbGrid, use the following to make the picklist
appear with just one click
If (DbGrid1.Column.PickList.Count > 0) then begin
keybd_event (VK_F2, 0, 0, 0);
keybd_event (VK_F2, 0, KEYEVENTF_KEYUP, 0);
keybd_event (VK_MENU, 0, 0, 0);
keybd_event (VK_DOWN, 0, 0, 0);
keybd_event (VK_DOWN, 0, KEYEVENTF_KEYUP, 0);
keybd_event (VK_MENU, 0, KEYEVENTF_KEYUP, 0);
end
If you still want to make use of the 0/1 storage, you would need to
write code in the OnGetText and OnSetText of the field, doing the
contents <> display conversion in whatever way is suitable for you.
Manuel Algora
cen...@wanadoo.es
> And this a picklist with True and False (some grids do show a
> checkbox, but my solution is simpler, though not so fancy).
I think a checkbox is the simpliest way :-)
I've drawn now a DBCheckbox at Runtime in the DBGrid cell and this works
fine (DBCheckbox has the very good properties ValuesChecked and
ValuesUnchecked, which makes database life in this case very easy).
Borland should make their DBGrid much more stronger in the next Delphi
version than it is now.
Regards
Stephan Schneider
"Manuel Algora" <cen...@wanadoo.es> schrieb im Newsbeitrag
news:cvj7cuki59ksv6ee5...@4ax.com...
I'm quite new in Delphi and would much appreciate if you would post the code
of how you did this
Regards
Jochen Lang
EGG IT-Services
>Borland should make their DBGrid much more stronger in the next Delphi
>version than it is now.
Certainly. It's too bare bones, and making it a bit more useful can be
done easily when you own the code. A different thing for us, when so
many things are kept Private. So, at least, I would be content if they
promote the visibility of some properties and methods: UpdateRowCount,
VisibleRowCount, CMFontChanged...
Manuel Algora
cen...@wanadoo.es
"Manuel Algora" <cen...@wanadoo.es> wrote in message
news:0qfacuk1t900j5a02...@4ax.com...
> On Mon, 22 Apr 2002 16:44:45 +0200, "Stephan Schneider"
> <stephan....@web.de> wrote:
>
> >Borland should make their DBGrid much more stronger in the next Delphi
> >version than it is now.
>
> Certainly. It's too bare bones,
It looks like you have seen the "New Flash On Old Bones" banner <g>.
http://www.quasidata.com/images/dbaltgrid03.gif
> and making it a bit more useful can be
> done easily when you own the code. A different thing for us, when so
> many things are kept Private.
<self-advertisement>
See screenshots at http://www.quasidata.com/dbaltgrid.html how a DBGid
descendant can look like.
</self-advertisement>
--
Andrei Fomine.
DbAltGrid - multi-line layout, RTF and graphics of any kind in DBGrid.
Transfer@once - full-blown clipboard and drag-and-drop transfer in native
MS Office formats to/from any control.
www.quasidata.com
Well, not until now!
><self-advertisement>
>See screenshots at http://www.quasidata.com/dbaltgrid.html how a DBGid
>descendant can look like.
></self-advertisement>
I have your DbAltGrid, and it's a feat that you could derive it from
TCustomDbGrid. As I enjoy writing my own components -I program for
fun-, I try also to make my own DbGrid, but had to tweak the
DbGrid.pas unit, by adding a prefix to the classes, promoting the
visibility of some things, and deriving from these classes. My DbGrid
can now do several things which formerly were not possible -or rather,
only in a crappy way (RowCount and scrollbar synchronization posed the
worst problem).
BTW, I have DbAltGrid version 1.3 Can you email me how to get version
1.4?
Manuel Algora
cen...@wanadoo.es