 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Mon Dec 04, 2006 5:28 pm Post subject: Stringgrid problem, if anybody can help pls... |
|
|
Hi All,
I gave coding to edit directly into the stringgrid and a word wrap
coding also (Please see the below coding). But at a time both will not
work. If i want to edit directly into the cells of stringgrid the word
wrap will not work, if i remove the coding of goediting then the word
wrap will work find. Do anybody have a solution for this. I want to
edit directly into the stringgrid cell without using and edit control
and the word wrap should also happen, what can i do for this? If
anybody can help please help me......
For word wrap in the string grid. In this case i have to use an edit
box to edit the cell of the stringgrid
-----------------------------------------------------------
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
P : array[0..255] of Char;
RTRowHeight : integer;
begin
{ Here checks for the row and column and setting row width }
if (ARow >= 1) and (ACol = 2) then
begin
StringGrid1.Canvas.FillRect(Rect);
StrPCopy(P, StringGrid1.Cells[2, ARow]);
{ Here happens the word wrap }
RTRowHeight := DrawText(StringGrid1.Canvas.Handle, P, -1, Rect,
DT_WORDBREAK);
{ Here it adjust the rowheight according to the requirement. }
if RTRowHeight > StringGrid1.RowHeights[ARow] then
begin
StringGrid1.RowHeights[ARow]:= RTRowHeight + 2;
end;
end;
end;
-----------------------------------------------------------
In order to edit directly into a particular cell of the stringgrid
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow:
Integer;
var CanSelect: Boolean);
begin
if ((ACol = 2) and (ARow = 1)) then
begin
StringGrid1.Options := StringGrid1.Options + [goEditing];
end
else
begin
StringGrid1.Options := StringGrid1.Options - [goEditing];
end;
end;
-----------------------------------------------------------
Thanks in advance |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|