![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
|
|
#1
|
|||
|
|||
|
hola. alguien me puede ayudar, estot con c++ builder xe3 alguien sabe como guardar un archivo de texto desde un objeto stringGrid y despues recuperar ese texto y ponerlo en el StringGrid. el archivo esta delimitado por punto y coma
|
|
#2
|
||||
|
||||
|
Hola ralmic y bienvenido a Club Delphi
![]() Como a todos los que se inician te invitamos a que leas nuestra guía de estilo. Con respecto a tu consulta, podrías hacer: Código:
// Cargar contenido de archivo a StringGrid
void FileToStringGrid(const char *aFileName, TStringGrid *sg)
{
TStrings *sl = new TStringList;
sl->LoadFromFile(aFileName);
sg->RowCount = sl->Count;
for (int i=0; i < sl->Count; i++) {
sg->Rows[i]->Delimiter = ';';
sg->Rows[i]->DelimitedText = sl->Strings[i];
}
delete sl;
}
// Guardar contenido de StringGrid en archivo
void StringGridToFile(const char *aFileName, TStringGrid *sg)
{
TStrings *sl = new TStringList;
for(int r = 0; r < sg->RowCount; r++) {
String s = "";
for (int c = 0; c < sg->ColCount; c++)
s += sg->Cells[c][r] + ';';
s.SetLength(s.Length()-1);
sl->Add(s);
}
sl->SaveToFile(aFileName);
delete sl;
}
Código:
void __fastcall TForm1::btnLoadClick(TObject *Sender)
{
FileToStringGrid("C:\\Carpeta\\archivo.txt", StringGrid1);
}
void __fastcall TForm1::btnSaveClick(TObject *Sender)
{
StringGridToFile("C:\\Carpeta\\archivo.txt", StringGrid1);
}
![]()
__________________
Daniel Didriksen Guía de estilo - Uso de las etiquetas - La otra guía de estilo .... |
|
#3
|
|||
|
|||
|
gracias
gracias. enseguida probare el codigo
![]() |
![]() |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| Funciona en C++ Builder 6 y no en C++ Builder XE | dmartinezn | C++ Builder | 1 | 07-05-2012 21:08:42 |
| stringgrid en celda de otro stringgrid?? | noodle_ | OOP | 3 | 17-06-2008 13:36:01 |
| StringGrid | pollo_c | Gráficos | 2 | 08-11-2006 03:30:24 |
| StringGrid | jaime cotino | OOP | 6 | 26-05-2004 15:51:55 |
| StringGrid | acertij022 | OOP | 1 | 07-10-2003 03:43:26 |
|