| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
seth Cmdr

Registrado: 16 Nov 2003Mensajes: 129
|
Publicado: Mar 11 Jul, 2006 6:15 pm Asunto: Borrar todo el contenido de un StringGrid |
|
|
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 |
|
 |
Miguel Angel Torres Master


Registrado: 23 Abr 2006Mensajes: 282Ubicación: Siegen, Alemania
|
Publicado: Mar 11 Jul, 2006 11:18 pm Asunto: |
|
|
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 |
|
 |
seth Cmdr

Registrado: 16 Nov 2003Mensajes: 129
|
Publicado: Mie 12 Jul, 2006 12:08 am Asunto: Buen Punto |
|
|
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 |
|
 |
Miguel Angel Torres Master


Registrado: 23 Abr 2006Mensajes: 282Ubicación: Siegen, Alemania
|
Publicado: Mie 12 Jul, 2006 1:31 am Asunto: |
|
|
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 |
|
 |
Touchsoftwares Master


Registrado: 16 Dic 2002Mensajes: 869Ubicación: MEXICO Playa del Carmen
|
Publicado: Mie 12 Jul, 2006 3:59 am Asunto: |
|
|
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 |
|
 |
seth Cmdr

Registrado: 16 Nov 2003Mensajes: 129
|
Publicado: Jue 13 Jul, 2006 7:26 pm Asunto: |
|
|
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 |
|
 |
Miguel Angel Torres Master


Registrado: 23 Abr 2006Mensajes: 282Ubicación: Siegen, Alemania
|
Publicado: Jue 13 Jul, 2006 10:47 pm Asunto: |
|
|
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 |
|
 |
juanma Cmdr

Registrado: 17 Nov 2005Mensajes: 127Ubicación: Almeria - España
|
Publicado: Vie 14 Jul, 2006 9:14 am Asunto: |
|
|
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 |
|
 |
seth Cmdr

Registrado: 16 Nov 2003Mensajes: 129
|
Publicado: Sab 22 Jul, 2006 4:03 pm Asunto: cambiar el tamaño de las columnas |
|
|
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 |
|
 |
Miguel Angel Torres Master


Registrado: 23 Abr 2006Mensajes: 282Ubicación: Siegen, Alemania
|
Publicado: Sab 22 Jul, 2006 5:43 pm Asunto: |
|
|
| 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 |
|
 |
seth Cmdr

Registrado: 16 Nov 2003Mensajes: 129
|
Publicado: Sab 22 Jul, 2006 6:37 pm Asunto: me refiero es a tamaños diferentes |
|
|
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 |
|
 |
Jumanor Lt


Registrado: 28 Feb 2003Mensajes: 91Ubicación: tacna-Peru
|
Publicado: Sab 22 Jul, 2006 9:49 pm Asunto: |
|
|
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 |
|
 |
Miguel Angel Torres Master


Registrado: 23 Abr 2006Mensajes: 282Ubicación: Siegen, Alemania
|
Publicado: Dom 23 Jul, 2006 11:32 pm Asunto: |
|
|
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 |
|
 |
|