Board index » delphi » cannot focus invisible control

cannot focus invisible control

Hi

   I have a question about the DBgrid and PageControl. Now I have six
page control and each has it's own dbgrid.Now I have the problem if I
focuscontrol  to set the foucs in the DBgrid in the last page(Actually I
have tab to the last page), it will show the message cannot focus
invisible or disabled windows. But the dbgrid is enabled and visible.
What happening if i use TField.Focuscontrol? BTW, Is there other method
can act same as TField.Focuscontrol if I want to set the focus in one of
the cell of DBGRid

Regards
Alex Chan from Hong Kong

 

Re:cannot focus invisible control


Alex -
 >    I have a question about the DBgrid and PageControl. Now I have six
 > page control and each has it's own dbgrid.Now I have the problem if I
 > focuscontrol  to set the foucs in the DBgrid in the last page(Actually I
 > have tab to the last page), it will show the message cannot focus
 > invisible or disabled windows. But the dbgrid is enabled and visible.
 > What happening if i use TField.Focuscontrol? BTW, Is there other method
 > can act same as TField.Focuscontrol if I want to set the focus in one of
 > the cell of DBGRid

 > Regards
 > Alex Chan from Hong Kong

Only the currently active TTabSheet is visible. Since the TDBGrid is a
child of a TTabSheet, it is "not visible" unless the TTabSheet on
which it resides is visible. In addition to calling SetFocus, you need
to switch to the appropriate TTabSheet. Something like:

  PageControl1.ActivePage := TabSheet6;
  DBGrid6.SetFocus;

Good luck.

Kurt

Other Threads