Показать сообщение отдельно
  #4  
Старый 05.11.2007, 08:57
Аватар для The Shadow
The Shadow The Shadow вне форума
Продвинутый
 
Регистрация: 11.06.2007
Адрес: Уфа, Россия
Сообщения: 793
Репутация: 35
По умолчанию

Вот рабочий пример со StringGrid'ом:
Код:
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids;
type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    procedure FormCreate(Sender: TObject);
    procedure StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;
      const Value: String);
    procedure StringGrid1GetEditText(Sender: TObject; ACol, ARow: Integer;
      var Value: String);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
with StringGrid1 do
begin
Cells[0, 0]:='0';
Cells[1, 0]:='0';
Cells[2, 0]:='0';
end;
end;
procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol,
  ARow: Integer; const Value: String);
begin
try
StringGrid1.Cells[2, 0]:=IntToStr(StrToInt(StringGrid1.Cells[0, 0]) + StrToInt(StringGrid1.Cells[1, 0]));
except
end;
end;
procedure TForm1.StringGrid1GetEditText(Sender: TObject; ACol,
  ARow: Integer; var Value: String);
begin
if ACol = 2 then
Exit;
try
StrToInt(Value);
except
Value:='0';
end;
StringGrid1.Cells[2, 0]:=IntToStr(StrToInt(StringGrid1.Cells[0, 0]) + StrToInt(StringGrid1.Cells[1, 0]));
end;
end.
В StringGrid'e должно быть три столбца, и одна строка, в Option - goEditing поставь True, и не забудь указать события OnCrete у формы, и события OnGetEditText и OnSetEditText у StringGrid'a
__________________
Что делать, когда сломался комп:
1. Если вы юзер - делать ноги.
2. Если ремонтник - делать деньги.
3. Если вы программист - делать вид, что так было задумано.
Ответить с цитированием