如stringgrid1有三行三列,其中单元格stringgrid1.cells[2,2]的内容为 "请告诉我怎做!",
  当我在stringgrid1.cells[2,2]单元格中选择“告诉”两个字时,我如何得知我选择了“告诉”
  两个字,请高手指点!

解决方案 »

  1.   

    比如edit1.text:='请告诉我怎做!", 如果用户选择了“告诉”两个字,用edit1.seltext不是得到“告诉”两个字吗?但stringgrid1怎么处理?
      

  2.   

    TForm1 = class(TForm)
      ……
      privated
        Edit: TCustomEdit;
      ……procedure TForm1.StringGrid1GetEditText(Sender: TObject; ACol,
      ARow: Integer; var Value: String);
    var
      I: Integer;
    begin
      with TStringGrid(Sender) do
      for I := 0 to ComponentCount-1 do
      if Components[I] is TCustomEdit then
      begin
        Edit := TCustomEdit(Components[I]);
        Break;
      end;
    end;然后可以取得选中的内容:
    var
      S, E: Integer;
    begin
      if Edit <> nil then
      begin
        SendMessage(Edit.Handle, EM_GETSEL, Integer(@S), Integer(@E));
        Edit1.Text := Copy(Edit.Text, S+1, E-S);
      end;
    end;————————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    ————————————————————————————————————