Selected Text in Selected Cell of String Grid
Does anyone know a windows message or other way to tell a stringgrid not
to select the text in a cell.
The problem is when I use the OnSetEditText of TStringGrid. I Add an
Item To Cell[0, aRow] if some conditions are met. On Adding this the
text in Cell[aCell, aRow] becomes selected like having the AutoSelect
Property set to true on a TEdit
This Causes a problem if entering '10'. '1' meets the condition and gets
selected so the zero you enter next clears the '1' away.
Any Help will be greatly appreciated. Thanks in advance.
Davin Barrott
sl...@hits.net.au
Heres the simplified Source:
begin
Item:= Grid1.Objects[0, aRow] as TItem;
case aCol of
0:
begin
i:= StrToIntDef(Grid1.Cells[0, aRow], -1);
if assigned(Grid1.Objects[0, aRow]) then
(Grid1.Objects[0, aRow] as Titem).Free;
Grid1.Cells[1, aRow]:= ''; //Clear The Other
Cells
Grid1.Cells[4, aRow]:= '';
Grid1.Cells[5, aRow]:= '';
Grid1.Cells[6, aRow]:= '';
Grid1.Cells[7, aRow]:= '';
if i>-1 then
begin
//Check in a DB to see if i is a valid number
Item:= Titem.Create;
//If it is the last row in the Grid add another
if aRow= Grid1.RowCount-1 then
Grid1.RowCount:= Grid1.RowCount+1;
Item.Number:= i;
//Set all the other properties of Item
Grid1.Objects[0, aRow]:= Item; //Once this is done
the Text in Cell[0, aRow] is selected
Grid1.Cells[1, aRow]:= Item.Name;
Grid1.Cells[3, aRow]:= IntToStr(Item.Quant);
Grid1.Cells[4, aRow]:= IntToStr(Item.Number);
Grid1.Cells[5, aRow]:= '';
end;
end;
1:
begin
end;
end;
end;