Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 21-03-2013
Avatar de Cristhor1982
Cristhor1982 Cristhor1982 is offline
Miembro
NULL
 
Registrado: dic 2012
Posts: 60
Poder: 12
Cristhor1982 Va por buen camino
Pegar desde Clipboard a InputBox

Amigos, tengo una duda, puedo pegar por ejemplo

123,456,789
101,110,121,015
125
235-785
2512 8545

en un imputbox, que quede de esta forma

123,456,789,101,110,121,015,125,235,785,2512,8545

y luego de que quede delimitado por comas al aceptar el inputbox
lo llevo a un stringgrid y los valores en una columna especifica.

Si alguien me ayuda...FANTASTICO!!

Saludos
Responder Con Cita
  #2  
Antiguo 21-03-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Cristhor1982.

Basándome en el ejemplo de tu mensaje:
Cita:
123,456,789
101,110,121,015
125
235-785
2512 8545
Podrías hacer:
Código Delphi [-]
...
uses Clipbrd;

procedure ClipToColRow(SG: TStringGrid; const aCol, aRow:Integer; const Str: string);
var
  SL: TStrings;
  i : Integer;
begin
  SL:= TStringList.Create;
  try
    SL.Delimiter     :=',';
    SL.DelimitedText := Str;
    SG.RowCount:= SL.Count + 1;
    for i := 0 to SL.Count-1 do
       SG.Cells[SG.FixedCols, SG.FixedRows+i] := SL[i];
  finally
    SL.Free
  end
end;

procedure TForm1.btnToSGridClick(Sender: TObject);
var
  Str: string;
  SL: TStrings;
  i : Integer;
begin
  if Clipboard.HasFormat(CF_TEXT) then
  begin
    SL:= TStringList.Create;
    try
      SL.Text:= Clipboard.AsText;
      for i:= 0 to SL.Count-1 do
        if i < SL.Count-1 then SL[i]:= SL[i] + ',';
      Str := SL.Text;
      Str := StringReplace(Str, '-', ',', [rfReplaceAll]);
      Str := StringReplace(Str, ' ', ',', [rfReplaceAll]);
      Str := StringReplace(Str, #10,  '', [rfReplaceAll]);
      Str := StringReplace(Str, #13,  '', [rfReplaceAll]);
      Clipboard.AsText:= Str;
    finally
      SL.Free
    end
  end;
  Str := InputBox('Dato', ':', Str); // esto podría ser innecesario...
  ClipToColRow(StringGrid1, 1, 1, Str);
end;
...
Podrías enviar directamente la variable Str como parámetro de la función ClipToColRow sin pasar por el InputBox.

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 21-03-2013 a las 21:39:09. Razón: comentario
Responder Con Cita
  #3  
Antiguo 21-03-2013
Avatar de Cristhor1982
Cristhor1982 Cristhor1982 is offline
Miembro
NULL
 
Registrado: dic 2012
Posts: 60
Poder: 12
Cristhor1982 Va por buen camino
Thumbs up

Wow!!, excelente justo en el clavo, ahora tengo k modificar un par de cosas y toy, Muchas Gracias!!!

Te Pasaste ...Necesito un profe como tu 100%

Saludos

Cita:
Empezado por ecfisa Ver Mensaje
Hola Cristhor1982.

Basándome en el ejemplo de tu mensaje:


Podrías hacer:
Código Delphi [-]
...
uses Clipbrd;

procedure ClipToColRow(SG: TStringGrid; const aCol, aRow:Integer; const Str: string);
var
  SL: TStrings;
  i : Integer;
begin
  SL:= TStringList.Create;
  try
    SL.Delimiter     :=',';
    SL.DelimitedText := Str;
    SG.RowCount:= SL.Count + 1;
    for i := 0 to SL.Count-1 do
       SG.Cells[SG.FixedCols, SG.FixedRows+i] := SL[i];
  finally
    SL.Free
  end
end;

procedure TForm1.btnToSGridClick(Sender: TObject);
var
  Str: string;
  SL: TStrings;
  i : Integer;
begin
  if Clipboard.HasFormat(CF_TEXT) then
  begin
    SL:= TStringList.Create;
    try
      SL.Text:= Clipboard.AsText;
      for i:= 0 to SL.Count-1 do
        if i < SL.Count-1 then SL[i]:= SL[i] + ',';
      Str := SL.Text;
      Str := StringReplace(Str, '-', ',', [rfReplaceAll]);
      Str := StringReplace(Str, ' ', ',', [rfReplaceAll]);
      Str := StringReplace(Str, #10,  '', [rfReplaceAll]);
      Str := StringReplace(Str, #13,  '', [rfReplaceAll]);
      Clipboard.AsText:= Str;
    finally
      SL.Free
    end
  end;
  Str := InputBox('Dato', ':', Str); // esto podría ser innecesario...
  ClipToColRow(StringGrid1, 1, 1, Str);
end;
...
Podrías enviar directamente la variable Str como parámetro de la función ClipToColRow sin pasar por el InputBox.

Saludos.
Responder Con Cita
Respuesta



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
Pegar de Clipboard a StringGrid Cristhor1982 Varios 13 23-05-2013 09:47:47
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
Copiar Y Pegar Una Bd Desde Delphi ChristianP Conexión con bases de datos 7 28-06-2007 16:43:39
Pegar fichero desde portapapeles Rudorf API de Windows 2 17-04-2007 05:45:34


La franja horaria es GMT +2. Ahora son las 11:54:11.


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