Club Builder - Foros de discusión Club Builder
Foro de C++Builder en español
 
 FAQFAQ   BuscarBuscar   MiembrosMiembros   Grupos de UsuariosGrupos de Usuarios   RegistrarseRegistrarse 
 PerfilPerfil   Entra para ver tus mensajes privadosEntra para ver tus mensajes privados   EntrarEntrar 

Borrar todo el contenido de un StringGrid

 
Publicar nuevo tema   Responder al tema    Foros de discusión -> Consultas
Ver tema anterior :: Ver tema siguiente  
Autor Mensaje
Mensaje    Asunto: Borrar todo el contenido de un StringGrid Responder citando

Buenas Tardes.

me gustaria saber como puedo borrar toda la informacion que se encuentra en un StringGrid. algo asi
en el Memo se puede limpiar todo el contenido Memo1->Clear();

lo puedo hacer creando StringGrid dinamicos y cuando los termine los elimino y cuando los necesite los vuelvo a crear..

pero considero que debe haber una forma para hacer esto.

que la informacion de este toda sea NULL osea que no tenga nada


Ultima edición por seth el Jue 13 Jul, 2006 7:28 pm, editado 1 vez
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email Yahoo Messenger MSN Messenger
Mensaje    Asunto: Responder citando

No puedes recorrerlo y poner en blanco cada posición y ya?

Código:

for(int x=0;x<=StringGrid1->ColCount;x++)
for(int y=0;y<=StringGrid1->RowCount;y++)
StringGrid1->Cells[x][y]="";

_________________
Entre más sé, sé que nada sé
----------------------------------
Miguel Angel Torres Arredondo
Siegen - Deutschland
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor MSN Messenger
Mensaje    Asunto: Buen Punto Responder citando

Hola Gracias por tu interes.

Si eso podria funcionar pero si se usa muchas veces podria tomar mucho tiempo de acuerdo a la cantidad de datos que se esten manejando.
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email Yahoo Messenger MSN Messenger
Mensaje    Asunto: Responder citando

y si metieses esa rutina en un hilo?, tal véz asi podrías optimizar tiempo. suerte....
_________________
Entre más sé, sé que nada sé
----------------------------------
Miguel Angel Torres Arredondo
Siegen - Deutschland
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor MSN Messenger
Mensaje    Asunto: Responder citando

Lo que yo hago es:

Rows=0
Cols=0
y luego regreso a los valores orginales

saludos
_________________
Ing. Gabriel Góngora Navarrete
TouchSoftwares Inc

http://www.touchsoftwares.com
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor MSN Messenger
Mensaje    Asunto: Responder citando

Buenas Tardes.

Yo puedo eleminar el objeto llamando a su destructor

StringGrid1->~TStringGrid();

y asi elimino toda la informacion que este lleve.

pero cuando lo vuelva a necesitar como lo puedo volver a crear como llamo al constructor del objeto.
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email Yahoo Messenger MSN Messenger
Mensaje    Asunto: Responder citando

Lo mejor es que crees al objeto dinamicamente así:

Código:

TStringGrid *StringGrid1=new TStringGrid(this) ;
StringGrid1->Parent=this;
StringGrid1->Name="StringGrid1";
StringGrid1->ColCount=5;
StringGrid1->RowCount=5;
//El valor de ajustar en patalla ya se selecciona según el número de
//Columnas y Filas a implementar
//Yo lo ajusté a una estructura de 5*5
StringGrid1->Width=1.03*(StringGrid1->DefaultColWidth)*(StringGrid1->ColCount);//Para Ajustar en pantalla.
StringGrid1->Height=1.1*(StringGrid1->DefaultRowHeight)*(StringGrid1->RowCount);//Para Ajustar en pantalla.
//El resto de propiedades que quieras agregar


y para eliminarlo así:

Código:

TStringGrid *StringGrid;
for(int i=0; i < ComponentCount; i++)
if (Components[i]->ClassNameIs( "TStringGrid" ))
{
StringGrid = (TStringGrid *)Components[i];
if ( StringGrid->Name=="StringGrid1" ) delete StringGrid;
}


Si necesitas volver a crearlo vuelves a llamar al código para crear el botón y listo. Sería mejor introducir estos códigos en dos funciones algo así como Crear() y Eliminar(). Espero esto te sirva. Suerte....
_________________
Entre más sé, sé que nada sé
----------------------------------
Miguel Angel Torres Arredondo
Siegen - Deutschland
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor MSN Messenger
Mensaje    Asunto: Responder citando

Yo de momento (y me gustaria encontrar otro método ya que el de Touchsoftware pide un * TList...) utilizo:
Código:

for (int i = 1; i< sg.RowCount; i++)
  sg->Rows[i]->Clear();

sg->RowCount = 2;

(para mi necesidad dejo la cabecera y una linea en blanco)
Aun no entenderé como la VCL esta diseñada para que cuando uno pone
Código:

sg->RowCount = 1;

No se eliminen todos los datos y los mantenga en memoria. Para que!!!
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Mensaje    Asunto: cambiar el tamaño de las columnas Responder citando

Buenos Dias.

me gustaria saber como como se puede cambiar el tamaño de las columnas mediante codigo o si se puede cambiar para que sea cambiada en tiempo de ejecuccion el ancho de las columnas.
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email Yahoo Messenger MSN Messenger
Mensaje    Asunto: Responder citando

Código:

TStringGrid *StringGrid1=new TStringGrid(this) ;
StringGrid1->Parent=this;
StringGrid1->Name="StringGrid1";
StringGrid1->ColCount=5;
StringGrid1->RowCount=5;
StringGrid1->DefaultColWidth=5; //Ancho de Columna
StringGrid1->DefaultRowHeight=5; //Ancho de Fila


Suerte.[/code]
_________________
Entre más sé, sé que nada sé
----------------------------------
Miguel Angel Torres Arredondo
Siegen - Deutschland
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor MSN Messenger
Mensaje    Asunto: me refiero es a tamaños diferentes Responder citando

hola. gracias por tu respuesta.

me gustaria hacerlo pero con diferentes valores para las columnas como en exel que cada columna puede tener un valor diferente en ejecucon se
puede modificar asi
en la propiedad Options
goColSizing colocando en verdadero
y permite modificarles el tamaño a las columnas...

pregunta adicional

como puedo accedar a la propiedad Options del StringGrid para cambiarle un valor para este "goColSizing" caso en tiempo de ejecucion ejemplo

void __fastcall TForm1::Button1Click(TObject *Sender)
{
// colocar movible las columnas del StringGrid
StringGrid1->Options // ??
// quiero modificar goColSizing para colocarle true
}
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email Yahoo Messenger MSN Messenger
Mensaje    Asunto: Responder citando

Holas:

Código:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
 TGridOptions Options;
 Options<<goColSizing;
 StringGrid1->Options=Options;
}


mejor

Código:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
 StringGrid1->Options<<goColSizing;
}




Saludos
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email Visitar sitio web del autor MSN Messenger
Mensaje    Asunto: Responder citando

Tal y como te dijo jumanor puedes hacer esto:

Código:

TStringGrid *StringGrid1=new TStringGrid(this) ;
StringGrid1->Parent=this;
StringGrid1->Name="StringGrid1";
StringGrid1->ColCount=5;//Número de Columnas deseadas
StringGrid1->RowCount=5;//Número de Filas deseadas
StringGrid1->DefaultColWidth=20; //Ancho de Columna deseado
StringGrid1->DefaultRowHeight=20; //Ancho de Fila deseado
StringGrid1->Options<<goColSizing<<goEditing;//Propiedades deseadas


Recordar en la ayuda aparecen las propiedades explicadas, las mismas del object inspector:

Cita:

goFixedVertLine:Vertical lines are drawn to separate the fixed (nonscrolling) columns in the grid.

goFixedHorzLine:Horizontal lines are drawn to separate the fixed (nonscrolling) rows in the grid.

goVertLine:Vertical lines are drawn to separate the scrollable columns in the grid.

goHorzLine:Horizontal lines are drawn to separate the scrollable rows in the grid.

goRangeSelect:Users can select ranges of cells at one time. goRangeSelect is ignored if Options includes goEditing.

goDrawFocusSelected:Cells with input focus are drawn with a special highlight color, just like selected cells without input focus. If goDrawFocusSelected is not included, the cell with input focus is distinguished by a focus rectangle, not by a special background color.

goRowSizing:Scrollable rows can be individually resized.

goColSizing:Scrollable columns can be individually resized.

goRowMoving:Scrollable rows can be moved using the mouse.

goColMoving:Scrollable columns can be moved using the mouse.


goEditing: Users can edit the contents of cells. When goEditing is included in Options, goRangeSelect has no effect.

goTabs:Users can navigate through the cells in the grid using Tab and Shift+Tab.

goRowSelect:Entire rows are selected rather than individual cells. If goRowSelect is included in Options, goAlwaysShowEditor has no effect.

goAlwaysShowEditor:The grid is locked into edit mode. The user does not need to use Enter or F2 to turn on EditorMode. If Options does not include goEditing, goAlwaysShowEditor has no effect. If Options includes goRowSelect, goAlwaysShowEditor has no effect.

goThumbTracking:The grid image updates while the user is dragging the thumb of the scroll bar. If goThumbTracking is not included, the image does not update until the user releases the thumb in a new position.



Espero te sirva la inforamación. Suerte.
_________________
Entre más sé, sé que nada sé
----------------------------------
Miguel Angel Torres Arredondo
Siegen - Deutschland
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor MSN Messenger
Mostrar mensajes de anteriores:   
Cambiar a:  
No puedes publicar temas nuevos en este foro
No puedes responder a temas en este foro
No puedes editar tus mensajes en este foro
No puedes borrar tus mensajes en este foro
No puedes votar en las encuestas de este foro


Hosting WordPress Indedmedia desde 3,99 €
© 2002–2026 Club Builder · Funciona con phpBB.