#1 2011-01-10 11:22:26

Bojop
Member
From: Wolder
Registered: 2011-01-05
Posts: 28

Problem with data in a grid

Hello,

Very nice framework.

I am trying the sample programs.
When added a grid I ran into a problem.
The text or integer values in a grid are displayed one char shorter than the original value.
So, an integer value 0 to 9 is not shown in the grid. Also not in the ID column.

I changed in SQLite3Commons

function TSQLTable.GetWP(Row, Field: integer; Dest: PWideChar; MaxDestChars: cardinal): integer;
var P: PUTF8Char;
begin
  P := Get(Row,Field);
  result := Utf8ToUnicode(Dest,MaxDestChars,PAnsiChar(P),StrLen(P))-1;
end;

to

  result := Utf8ToUnicode(Dest,MaxDestChars,PAnsiChar(P),StrLen(P));

with presents the correct data in the grid.

I only don't know if this will give other problems.

Offline

#2 2011-01-10 13:57:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Problem with data in a grid

I think it comes from a change in Delphi RTL.

In Delphi 6/7, here is how it's coded:

function Utf8ToUnicode(Dest: PWideChar; MaxDestChars: Cardinal; Source: PChar; SourceBytes: Cardinal): Cardinal;
  (...)
  Result := count+1;
end;

It seems it has changed in later Delphi versions...
Which version do you use?

So I've added a new overloaded function named UTF8ToWideChar(), and changed the Utf8ToUnicode() RTL call to this new function.
Our  UTF8ToWideChar function is even faster than RTL Utf8ToUnicode function.

Thanks for your feedback.

Offline

#3 2011-01-10 20:31:34

Bojop
Member
From: Wolder
Registered: 2011-01-05
Posts: 28

Re: Problem with data in a grid

Yes, it is different in XE.

OK, that's nice, thank you for the new function.

Offline

#4 2011-03-22 00:31:34

coblongpamor
Member
From: Bali-Indonesia
Registered: 2010-11-07
Posts: 130
Website

Re: Problem with data in a grid

Is it possible to Get Record from CurrentFocusedRow from TDrawGrid (TSQLTableToGrid)?

so i can write code like bellow (maybe)

procedure TForm1.DrawGrid1FocusedRow(Sender: TObject; aFocusedRow:TSQLRecord);
var
   aPeople:TSQLPeople;
begin
   aPeople:=aFocusedRow.
end;

and, if possible to Select multiple row.

var
  i:integer;
  aPeople:TSQLPeople;
begin
  for i:=0 to Drawgrid1.selectedrows.count-1 do
  begin
    Drawgrid1.selectedrows[i].focused;
    aPeople:=Drawgrid1.FocusedRow;
  end;
end;

thanks.

Last edited by coblongpamor (2011-03-22 00:37:27)

Offline

#5 2011-03-22 08:15:03

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Problem with data in a grid

Use SelectedID function to retrieve the focused row ID.
Then you can retrieve it in a TSQLRecord.

I've added a SelectedRecord function for rev. 1.13 to directly retrieve a TSQLRecord instance.

For multi-selection:
1. Call SetFieldLengthMean() with aMarkAllowed parameter = true to enable row selection (a checkbox is added left side of the grid)
2. Use MarkedTotalCount, MarkAvailable and Marked[] properties to retrieve (or set) the marked rows
3. You have SetMark() method to perform some standard actions on marking

Offline

#6 2011-03-23 03:05:11

coblongpamor
Member
From: Bali-Indonesia
Registered: 2010-11-07
Posts: 130
Website

Re: Problem with data in a grid

Tanks AB for the response, i'll try the functions that you suggest.

Offline

Board footer

Powered by FluxBB