#1 2011-11-14 09:34:04

proto
Member
From: Russia, Kostroma
Registered: 2011-09-12
Posts: 31

how do I change the header names in DrawGrid?

Table := Database.ExecuteList([], 'select * from base');
TSQLTableToGrid.Create(DrawGrid, Table, Database);

how to change the header of the received table? I want to Russify them, as I understood the module to change the SQLite3i18n prednaznichen not dynamically change the text

Last edited by proto (2011-11-14 09:34:26)

Offline

#2 2011-11-14 10:54:00

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

Re: how do I change the header names in DrawGrid?

In its current implementation, the SQLite3i18n unit does handle the header translation (as stated by the documentation).

In fact, if you look at the following code in SQLite3UI:

...
    if ARow=0 then begin
      // 1. 1st row = field name: bold + centered translated text, with sort indicator
      if not Assigned(OnValueText) or
         not OnValueText(Table,ACol,0,StringValue) then
        StringValue := Table.GetCaption(0,ACol); // auto translated
...

The header caption will be translated using LoadResStringTranslate() - so SQLite3i18n unit will work here.

Therefore, if you add the TSQLRecord to your SQlite3i18n class to be translated, or add manually the header in the translation text list, it will be translated automatically.

Or you can use the OnValueText() property of TSQLTableToGrid to handle the translation in a full customized way (without SQLite3i18n).
You can put your russian test encoded in UTF-8, and it will work as expected.

Offline

#3 2011-11-16 12:59:23

proto
Member
From: Russia, Kostroma
Registered: 2011-09-12
Posts: 31

Re: how do I change the header names in DrawGrid?

I'm trying to determine the visibility of the ID column but the result lie all the time

in documentation:
function IDColumnHide: boolean;
- return true is ID was succesfully hidden, false if not possible

in code:

function TSQLTable.IDColumnHide: boolean;
var FID,R,F: integer;
    S,D1,D2: PPUTF8Char;
begin
  // 1. check if possible
  result := false;
  if (self=nil) or Assigned(fIDColumn) or (FieldCount<=1) then
    exit; // already hidden or not possible <<<--- always false if hidden

Offline

#4 2011-11-16 13:38:25

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

Re: how do I change the header names in DrawGrid?

This method is a setter, not a getter.

I think that FieldIndexID method will return -1 if no ID column is available.

Offline

#5 2011-11-18 12:31:19

proto
Member
From: Russia, Kostroma
Registered: 2011-09-12
Posts: 31

Re: how do I change the header names in DrawGrid?

how search hidden id?

Table := Database.ExecuteList([], 'select Id, TipogNum, Fam, Im, Ot, DateBorn, MestoRab from DataRecord');
ttg := TSQLTableToGrid.Create(dgDataRecord, Table, Database);
ttg.OnValueText := OnListText;
ttg.IDColumnHide; //if comment this line i bring search result

dgDataRecord.Row := Table.SearchValue('5', 1, 0, nil); // search record with id = 5

Last edited by proto (2011-11-18 13:22:37)

Offline

#6 2011-11-18 13:07:46

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

Re: how do I change the header names in DrawGrid?

Use the dedicated method named TSQLTable.RowFromID

Offline

Board footer

Powered by FluxBB