Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #4  
Antiguo 08-12-2012
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Poder: 23
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
Cristhor1982,

Revisa este código:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, ClipBrd;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    ClipBoard2StringGrid: TButton;
    StringGrid2Clipboard: TButton;
    txtRows: TEdit;
    Label1: TLabel;
    txtCols: TEdit;
    Label2: TLabel;
    procedure ClipBoard2StringGridClick(Sender: TObject);
    procedure StringGrid2ClipboardClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// Divide una cadena de Texto por palabras
procedure Split(const Delimiter: Char; Input: string; const Strings: TStrings);
begin
   Strings.Clear;
   Strings.Delimiter := Delimiter;
   Strings.DelimitedText := Input;
end;

// Copia de Clipboard a StringGrid
procedure TForm1.ClipBoard2StringGridClick(Sender: TObject);
var
   StrList : TStringList;
   Row, Col, Data : Integer;

begin
   StrList := TStringList.Create;

   if Clipboard.HasFormat(CF_TEXT) then
   begin
      Split(' ',Clipboard.AsText,StrList);
      StringGrid1.FixedRows := 1;
      StringGrid1.FixedCols := 1;
      StringGrid1.RowCount := StrToIntDef(txtRows.Text,1)+1; // Por defecto una fila
      StringGrid1.ColCount := StrToIntDef(txtCols.Text,1)+1; // Por defecto una columna

      for Row:= 1 to StringGrid1.RowCount do
         StringGrid1.Rows[Row].Clear;

      for Col:= 1 to StringGrid1.ColCount do
         StringGrid1.Cols[Col].Clear;

      Data := 0;
      for Row:= 1 to StringGrid1.RowCount do
         for Col:= 1 to StringGrid1.ColCount-1 do
         begin
            if (Data <= StrList.Count-1) then
            begin
               StringGrid1.Cells[Col,Row] := StrList.Strings[Data];
               inc(Data);
            end
         end
   end;

   StrList.Free;
end;

// Copia de StringGrid a Clipboard
procedure TForm1.StringGrid2ClipboardClick(Sender: TObject);
var
   StringData : String;
   Row,Col : Integer;

begin
   Clipboard.Clear;

   StringData := '';

   for Row := 1 to StringGrid1.RowCount do
   begin
      for Col := 1 to StringGrid1.ColCount-1 do
      begin
         if (StringGrid1.cells[Col,Row] <> ' ') then
            StringData := StringData + StringGrid1.cells[Col,Row] + #9;
      end;
      StringData := StringData + #13 + #10;
   end;

   Clipboard.AsText := StringData;
end;

end.
El código anterior permite copiar por medio del Clipboard filas y columnas de data desde y hacia un control TStringGrid, es práctico para el intercambio de data con Excel.

Espero sea útil

Nelson.

Última edición por nlsgarcia fecha: 08-12-2012 a las 03:22:55.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Copiar/pegar desde el Clipboard a otra Aplicación broly7 Varios 4 07-03-2011 17:08:53
Pegar imagen desde el Portapapeles (Clipboard) gluglu Gráficos 8 20-10-2010 15:09:55
tabla a clipboard picap Varios 4 13-05-2010 08:23:07
Copiar Y Pegar texto en las celdas de un StringGrid rgstuamigo OOP 2 01-12-2008 13:55:51
Una clase al ClipBoard bustio OOP 2 07-07-2004 00:35:16


La franja horaria es GMT +2. Ahora son las 08:08:22.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi