Page 1 of 1

Center table.col

Posted: Sat Apr 05, 2008 8:56 am
by j&b
Hello

This sample clears table-columns (is oK).

I want to set table-columns (3 to 6) to center, left or right.
What's to do ? (important lines are 24, 25 and 28!! ).


Jürgen



//6spaltige Tabelle - Spalten 3 bis 6 sollen zentriert,linksbündig oder rechtsbündig formatiert werden

1 procedure TForm1.Button1Click(Sender: TObject);
2 var r,c, itemNo,data, styleNo,paraNo, v,b: integer;
3 s: string;
4 item: TCustomRVItemInfo;
5 begin
6
7 if (not memo.GetCurrentItemEx(TRVTableItemInfo, rve, TCustomRVItemInfo(rveTable))) then begin
8 ShowMessage('Es wurde keine Tabelle gewählt!');
9 exit;
10 end;
11
12 try
13 memo.GetCurrentItemEx(TRVTableItemInfo, rve, item);
14 ItemNo := memo.GetItemNo(rveTable);
15 memo.BeginItemModify(ItemNo, Data);
16 anzSpa_rve:= rveTable.Rows[0].Count;
17
18 s:=''; v:=2; b:=5; //Spalten 3 bis 6
19
20 for r := 0 to rveTable.Rows.Count-1 do begin
21 for c:=v to b do begin
22 if rveTable.Cells[r,c]<>nil then begin
23 if (rveTable.Cells[r,c].GetRVData.GetItemStyle(0)>=0) then begin

24 StyleNo := rveTable.Cells[r,c].GetRVData.GetItemStyle(0); //übernimmt bestehende Formatierung
25 ParaNo := rveTable.Cells[r,c].GetRVData.GetItemPara(0);

26 //s:=rveTable.Cells[r,c].GetRVData.GetItemTextA(0); //übernimmt Zellinhalt
27 rveTable.Cells[r,c].clear;


28 rveTable.Cells[r,c].AddNL('',StyleNo,ParaNo); //Zelle muss belegt werden, aber ... (siehe 24, 25)


29 //rveTable.Cells[r,c].AddNL(s,StyleNo,ParaNo); //übergibt Zellinhalt + übernimmt bestehende Formatierung
30 s:='';
31 end;
32 end;
33 end;
34 end;
35
36 finally
37 if rveTable<>nil then begin
38 memo.EndItemModify(ItemNo, Data);
39 memo.Change;
40 end;
41 end;
42 end;

Re: Center table.col

Posted: Sat Apr 05, 2008 10:05 am
by j&b
I think I have found a solution:


24 StyleNo := rveTable.Cells[r,c].GetRVData.GetItemStyle(0); //übernimmt bestehende Formatierung
25 //ParaNo := rveTable.Cells[r,c].GetRVData.GetItemPara(0);
// 0: ganz links, 1: zentriert, 2: links mit Abstand ?: right

28 rveTable.Cells[r,c].AddNL('',StyleNo,1);


Does something know the Parameter of right-alignment ?

Posted: Sun Apr 06, 2008 7:58 am
by Sergey Tkachenko
I'll create an example when I return (after April, 13)

Posted: Thu Apr 10, 2008 2:16 pm
by j&b
Hello Sergey,

do you mean something like this ?

procedure TForm1.sbTesten1Click(Sender: TObject);
var i: integer;
begin
if query1.state in [dsEdit, dsInsert] then query1.post;
if (not memo.GetCurrentItemEx(TRVTableItemInfo, rve, TCustomRVItemInfo(rveTable))) then begin
showMessage('Geht nicht !'+#10+'Tabelle muss den Fokus besitzen.');
exit;
end;
try
for i:= 2 to 5 do begin
if i<>1 then begin
rveTable.SelectCols(i,1); //1 eine Spalte zur Zeit markieren
FontSize:= 9; memo.ApplyStyleConversion(rv_APPLYFONTSIZE);
SetAlignmentToUI(rvaRight); memo.ApplyParaStyleConversion(PARA_ALIGNMENT);
end;
end;
except
end;
memo.deselect;
end;

Posted: Tue Apr 15, 2008 3:53 pm
by Sergey Tkachenko
Sorry, do you need to implement this as an editing operation (that can be undone by user) or not?
For an editing operation, your code is correct: select the proper cells and call ApplyParaStyleConversion.

Posted: Tue Apr 15, 2008 4:49 pm
by j&b
Hello Sergey,
thank you that you promise to your holding.
I use the above code.

Jürgen