Topic: Display the current record of a grid in a subform or outside the grid

Hi,

I'm new to MVD and I wonder, if it is generally possible to show the values of a record outside of a grid, e.g. in a subform or in separat textboxes etc.

If you navigate up or down to another record in the grid, the values in the separat textboxes or fields should be updated with the values of the grid.

See example in the Picture.

Is this possible?

Kind Regards
Wood

Post's attachments

Attachment icon MVD_Display_Grid_Record.png 7.83 kb, 262 downloads since 2015-10-28 

Re: Display the current record of a grid in a subform or outside the grid

Hello,


Yes, script for that:

procedure Form1_GridEmployees_OnKeyUp (Sender: string; var Key: Word; Shift, Alt, Ctrl: boolean);
begin
    Form1.edFirstname.Text := SQLExecute('SELECT firstname FROM employees WHERE id='+ Form1.GridEmployees.sqlValue);
    Form1.edLastname.Text :=  SQLExecute('SELECT lastname FROM employees WHERE id='+ Form1.GridEmployees.sqlValue);
    Form1.cbGroup.dbItemID := SQLExecute('SELECT IFNULL(id_groups, -1) FROM employees WHERE id='+ Form1.GridEmployees.sqlValue);
end;

procedure Form1_GridEmployees_OnCellClick (Sender: string; ACol, ARow: Integer);
begin
    Form1.edFirstname.Text := SQLExecute('SELECT firstname FROM employees WHERE id='+ Form1.GridEmployees.sqlValue);
    Form1.edLastname.Text :=  SQLExecute('SELECT lastname FROM employees WHERE id='+ Form1.GridEmployees.sqlValue);
    Form1.cbGroup.dbItemID := SQLExecute('SELECT IFNULL(id_groups, -1) FROM employees WHERE id='+ Form1.GridEmployees.sqlValue);
end;

begin

end.

also you can download project example:

Post's attachments

Attachment icon values from grid by sql.zip 7.06 kb, 453 downloads since 2015-10-29 

Dmitry.