Posted by Jose C P15709 In Reply to Word Wrap StringGrid posted by James Krawczyk : Hi All: I'm trying to create an application that does file hashing when you drag and drop the files onto it. To keep the design looking clean and since it has multiple hashes it returns I'm using a StringGrid to display the results. However the hash for SHA-512 and Whirlpool are (obviously) 512bit hashes and the resulting string is too long to fit into a StringGrid cell. : Is there any way to make the cell accept something past the limit (I've already tried increase that collum size to it's max). Or is there a simple way to make the StringGrid Word Wrap the hash results? : The code the puts the result into the grid is : if Form1.CheckWhirl.Checked = True then : Thanks
In my Delphi example, stringgrid is named "Grid" and long strings are in second column. 1. Make stringgrid column wider, in object inspector or in code when the form is showed: procedure TForm1.FormShow(Sender: TObject); begin Grid.ColWidths[0] := 80; Grid.ColWidths[1] := 500; // second column end; 2. Or show more lines in cell when stringgrid is drawn. In ondrawcell event, if the long strings are 64 characters: procedure TForm1.GridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin if ACol = 1 then begin Grid.Canvas.FillRect(Rect); Grid.Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, Copy(Grid.Cells[1, ARow], 1, 32)); Grid.Canvas.TextOut(Rect.Left + 2, Rect.Top + 16, Copy(Grid.Cells[1, ARow], 33, 32)); end; end; Experiment with row height and column width. Suggest: Arial 8 point, second column width 220, stringgrid defaultrowheight 33. Good luck! |