Jump to content


Photo

Two NxDBGrid Questions


  • Please log in to reply
3 replies to this topic

#1 Afiag

Afiag
  • Members
  • 117 posts

Posted 10 May 2010 - 10:18 PM

Hey Berg, I have two questions concerning NxDBGrid.

1. How can I let my Adoquery return all records but skipping the first 4 records. I thought using a Increment column and then somehow filter it only shows records with > 4 but as the increment field is just a column in the NXGrid I don't know how to work with it in a Adoquery.

2. I want flag icons (nationality) in one field in my grid. I have 245 flag icons. I added a picture column but noticed that can't load a picture from a file, only from a imagelist. Now I don't want to work with a image list with 245 images for a few reasons... I have a field called "country" in my table that has the exact flag filename as string for each record so in other words this:
mystring := 'images\flags\' + Adoquery1.FieldByName('country').AsString + '.png'
results in the exact path to the image that needs to be displayed for that record.

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 11 May 2010 - 12:26 AM

Hi Afiag,

Please read for answers:

1) Maybe something may be done with LIMIT keyword from SQL. I suggest that you try with it.

2) You may try with custom drawing (more at: http://dn.bergsoft.n...n-nextgrid.htm).

You can do this with even TextColumn. Load flag field in this column, but in custom draw draw a TBitmap of this flag.

I hope that this helps. If you get stuck maybe I can send you some code.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Afiag

Afiag
  • Members
  • 117 posts

Posted 11 May 2010 - 01:01 AM

Question 1.
I searched the net of the usage LIMIT which seems a mysql sort of thing, tried using it in my adoquery without much success

Question 2.
I (unsucesfully) tried the following ondrawcell:
if ACol = 5 then
NextDBGrid1.Cells[ACol][ARow] = TBitmap.Create.LoadFromFile('images\ficons\24\' + Adoquery1.FieldByName('flag').AsString + '.png');

Im prolly going in the wrong direction...

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 11 May 2010 - 01:24 AM

Hello Afiag,

1) Unfortunately I am not very skilled with ADO, but maybe you can add one additional field which will flag skipped records (and in WHERE clausule to exclude them).

2) You will need to write something like:

CODE
var
  ABitmap: TBitmap;
  FileName: string;
begin
  FileName := 'images\ficons\24\' + Adoquery1.FieldByName('flag').AsString + '.png';
  ABitmap := TBitmap.Create;
  ABitmap.LoadFromFile(FileName);
  NextDBGrid1.Canvas.Draw(CellRect.Left, CellRect.Top, ABitmap);


Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users