ClientDataSetMoveBy (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following example enables you to move the current selected cell in a db grid. The Up and Down buttons have their OnClick events assigned to the UpDownClick procedure. The Left and Right buttons have their OnClick events assigned to the LeftRightClick procedure. The Up and Left buttons have their Tag property set to -1, while the Down and Right buttons have their Tag property set to 1. MoveBy does not move the cell in the db grid, it only moves the selection. The data set is not edited. Notice that the Up button and the Down button are separate TButtons, not one TUpDown. The tags must be differentiated.

Code

void __fastcall TForm1::UpDownClick(TObject *Sender)
{
  CDS2->MoveBy((dynamic_cast<TComponent *>(Sender))->Tag);
  DBGrid2->SetFocus();
}

void __fastcall TForm1::LeftRightClick(TObject *Sender)
{
  DBGrid2->SelectedIndex = DBGrid2->SelectedIndex + (dynamic_cast<TComponent *>(Sender))->Tag;
  DBGrid2->SetFocus();
}

Uses

Personal tools
Assistance