| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
Oly Ens

Registrado: 07 Jul 2003Mensajes: 44Ubicación: Barcelona
|
Publicado: Lun 04 Ago, 2003 10:34 am Asunto: sobre stringgrid |
|
|
Hola,
una pregunta, cuando creo un stringgrid y tan solo quiero que sea de lectura sus valores, que ni siquiera puedan navegar por sus celdas etc..
Pero por defecto la primera celda siempre se me ilumiona con un color clhighlight, vamos que la selecciona por defecto. Qué puedo hacer para que no la seleccione?
merci |
|
| Volver arriba |
|
 |
sw Invitado
|
Publicado: Lun 04 Ago, 2003 11:30 am Asunto: StringGrid |
|
|
Para que no te seleccione ninguna celda lo que puedes hacer es lo siguiente :
TGridRect myRect;
myRect.Left = -1;
myRect.Top = -1;
myRect.Right = -1;
myRect.Bottom = -1;
StringGrid1->Selection = myRect; |
|
| Volver arriba |
|
 |
jotny Master


Registrado: 17 Feb 2004Mensajes: 226Ubicación: santiago
|
Publicado: Jue 17 Feb, 2005 11:23 pm Asunto: Algo de lo mismo |
|
|
yo capturo el evento on mouse down para poder discriminar con que boton se hizo el click.... pero solo cuando lo hago con el izquierdo se selecciona la fila, y si lo hago con el derecho , no se selecciona la fila....
como lo podria hacer?
que se seleccione ya sea haciendo click con el boton derecho y el izquiedo... teniendo el x,y y la columna y fila en donde se hizo click? |
|
| Volver arriba |
|
 |
mopa Cmdr

Registrado: 29 Jun 2004Mensajes: 145
|
Publicado: Dom 20 Feb, 2005 1:24 am Asunto: |
|
|
Poned la propiedad del StringGrid
DafaultDraw=true;
En el evento OnDrawCell y en el evento OnSelected Cell escribid lo siguiente:
Asi Conseguireis el efecto deseado.
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
if (State.Contains(gdFixed) )
{
StringGrid1->Canvas->Brush->Color=StringGrid1->FixedColor;
StringGrid1->Canvas->FillRect(Rect);
}else{
StringGrid1->Canvas->Brush->Color=StringGrid1->Color;
StringGrid1->Canvas->FillRect(Rect);
}
AnsiString txt=StringGrid1->Cells[ACol][ARow];
int length=StringGrid1->Cells[ACol][ARow].Length();
InflateRect(&Rect,-2,-2);
DrawText(StringGrid1->Canvas->Handle,txt.c_str(),length,&Rect,DT_VCENTER);
}
void __fastcall TForm1::StringGrid1SelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
CanSelect=false;
} |
|
| Volver arriba |
|
 |
mopa Cmdr

Registrado: 29 Jun 2004Mensajes: 145
|
Publicado: Lun 21 Feb, 2005 12:05 am Asunto: |
|
|
Fe de erratas:
DefaultDraw=false;
ya que lo que hacemos precisamente es dibujarlo nosotros.
Un saludo.
mopa |
|
| Volver arriba |
|
 |
|