Topic: Cell Padding

Hi Dmitry,


I got one of your sample help project about wrapping text in tGrid cells. Is it possible to apply cell padding too?
When wrapped text displayed  in cells they are visually difficult to differentiate as to which text belongs to which cell at first look. I tried row coloring but that also didn't help much.


Please see the sample project attached if needed.

Post's attachments

Attachment icon tGrid-TextWrap-CellColoring-CellPadding.zip 9.08 kb, 362 downloads since 2017-04-13 

Adam
God... please help me become the person my dog thinks I am.

Re: Cell Padding

Hello.


Yes you can set the padding to cells, example:

procedure Form1_GridEmployees_OnChange (Sender: string);
var
    i, c: integer;
begin
    Form1.GridEmployees.Columns[0].Padding := 10;
    Form1.GridEmployees.Columns[1].Padding := 20;
.......
Dmitry.

Re: Cell Padding

Thank you very much Dmitry...............


What about remaining two sides (top and bottom) of cells - Rows?

Adam
God... please help me become the person my dog thinks I am.

Re: Cell Padding

AD1408 wrote:

Thank you very much Dmitry...............


What about remaining two sides (top and bottom) of cells - Rows?

Unfortunately there is no a property for vertical padding.

Dmitry.

Re: Cell Padding

DriveSoft wrote:
AD1408 wrote:

Thank you very much Dmitry...............


What about remaining two sides (top and bottom) of cells - Rows?

Unfortunately there is no a property for vertical padding.


Hi Dmitry,


Could there be a workaround?
Is it possible to have X pixels space before and after the value in the cell or even inserting blank line before and after?

Adam
God... please help me become the person my dog thinks I am.

Re: Cell Padding

Check it out

procedure Form1_GridEmployees_OnChange (Sender: string);
var
    i, c: integer;
begin
    Form1.GridEmployees.Columns[0].Padding := 10;
    Form1.GridEmployees.Columns[1].Padding := 10;
    Form1.GridEmployees.Columns[2].Padding := 10;
    Form1.GridEmployees.Options := Form1.GridEmployees.Options or goRowResizing;

    c := Form1.GridEmployees.Columns.Count - 1;
    for i := 0 to c do
    begin
        Form1.GridEmployees.Columns[i].VerticalAlignment := taAlignTop;
        Form1.GridEmployees.Columns[i].WrapKind := wkWordWrap;
    end;

    c := Form1.GridEmployees.RowCount - 1;
    for i := 0 to c do
    begin
        Form1.GridEmployees.Cells[0,i] := #10#13+Form1.GridEmployees.Cells[0,i]+#10#13;
        Form1.GridEmployees.Cells[1,i] := #10#13+Form1.GridEmployees.Cells[1,i]+#10#13;
        Form1.GridEmployees.Cells[2,i] := #10#13+Form1.GridEmployees.Cells[2,i]+#10#13;
        Form1.GridEmployees.BestFitRow(i);
    end;
end;
Dmitry.

Re: Cell Padding

Thank you very much Dmitry........................


Please see images below:

https://s29.postimg.org/41oo1zuhj/zzzzz_Temp20.png

Adam
God... please help me become the person my dog thinks I am.

Re: Cell Padding

AD1408
Check it

        Form1.GridEmployees.Cells[0,i] :=Form1.GridEmployees.Cells[0,i]+#10#13;
        Form1.GridEmployees.Cells[1,i] :=Form1.GridEmployees.Cells[1,i]+#10#13;
        Form1.GridEmployees.Cells[2,i] := Form1.GridEmployees.Cells[2,i]+#10#13;
Dmitry.

Re: Cell Padding

DriveSoft wrote:

AD1408
Check it

        Form1.GridEmployees.Cells[0,i] :=Form1.GridEmployees.Cells[0,i]+#10#13;
        Form1.GridEmployees.Cells[1,i] :=Form1.GridEmployees.Cells[1,i]+#10#13;
        Form1.GridEmployees.Cells[2,i] := Form1.GridEmployees.Cells[2,i]+#10#13;

Thanks Dmitry.....
The above didn't work for me. Most likely I'm doing something wrong.
Please see the attached sample project.

Post's attachments

Attachment icon tGrid Columns and Row Spacing.zip 8.15 kb, 344 downloads since 2017-04-19 

Adam
God... please help me become the person my dog thinks I am.

Re: Cell Padding

Try to add more line breaks:

 procedure Form1_GridEmployees_OnChange (Sender: string);
var
    i, c: integer;
begin
    Form1.GridEmployees.Columns[0].Padding := 10;
    Form1.GridEmployees.Columns[1].Padding := 10;
    Form1.GridEmployees.Columns[2].Padding := 10;
    Form1.GridEmployees.Columns[3].Padding := 10;

    Form1.GridEmployees.Options := Form1.GridEmployees.Options or goRowResizing;

    c := Form1.GridEmployees.Columns.Count - 1;
    for i := 0 to c do
    begin
        Form1.GridEmployees.Columns[i].VerticalAlignment := taAlignTop;
        Form1.GridEmployees.Columns[i].WrapKind := wkWordWrap;
    end;

    c := Form1.GridEmployees.RowCount - 1;
    for i := 0 to c do
    begin                             
        Form1.GridEmployees.Cells[0,i] := Form1.GridEmployees.Cells[0,i]+#10#13#10#13#10#13#10#13;
        Form1.GridEmployees.Cells[1,i] := Form1.GridEmployees.Cells[1,i]+#10#13#10#13#10#13#10#13;
        Form1.GridEmployees.Cells[2,i] := Form1.GridEmployees.Cells[2,i]+#10#13#10#13#10#13#10#13;
        Form1.GridEmployees.BestFitRow(i);
    end;
end;
Dmitry.