Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I use windows short cuts for Cut, Copy, and Paste with TDBGrid?

DBGrid hints, tips, and tricks

How can I use windows short cuts for Cut, Copy, and Paste with TDBGrid?

by  Maladon  Posted    (Edited  )
This will make cut, copy, and paste work in all situations.
You have to turn off short cuts in the Menu's properties
to use this correctly. My thanks to those that demonstrated it to me.


Code:
//---------------------------------------------------------------------------
// CUT COPY AND PASTE FUNCTIONS: WORKS WITH GRID!
//---------------------------------------------------------------------------
void __fastcall TMainForm::Cut1Click(TObject *Sender)
{
   if(((dynamic_cast<TDBGrid *>(ActiveControl))
     &&(dynamic_cast<TDBGrid *>(ActiveControl)->EditorMode))
     &&(dynamic_cast<TInplaceEdit*>(ActiveControl->Controls[0])->SelLength > 0))
         ActiveControl->Controls[0]->Perform(WM_CUT, 0, 0);

   else ActiveControl->Perform(WM_CUT, 0, 0);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Copy1Click(TObject *Sender)
{
   if(((dynamic_cast<TDBGrid *>(ActiveControl))
     &&(dynamic_cast<TDBGrid *>(ActiveControl)->EditorMode))
     &&(dynamic_cast<TInplaceEdit*>(ActiveControl->Controls[0])->SelLength > 0))
         ActiveControl->Controls[0]->Perform(WM_COPY, 0, 0);

   else ActiveControl->Perform(WM_COPY, 0, 0);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Paste1Click(TObject *Sender)
{
   if ((dynamic_cast<TDBGrid *>(ActiveControl))
       && (dynamic_cast<TDBGrid *>(ActiveControl)->EditorMode))
            ActiveControl->Controls[0]->Perform(WM_PASTE, 0, 0);

   else ActiveControl->Perform(WM_PASTE, 0, 0);
}
//---------------------------------------------------------------------------
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top