CHECHE81
24-09-2010, 19:27:34
Saludos camaradas, con la novedad que ando manejando el bondadoso y famoso cxgrid junto con un cxnavigator asociado claro con su clientdataset y datasource, el detalle que al agregar un registro nuevo quiero ponerle un valor que ya tengo guardado en una variable o en algún campo de otra tabla y lo intento en 2 eventos:
Primero:
pprocedure TfmEstadoCuenta.cxNavigator1ButtonsButtonClick(Sender: TObject;
AButtonIndex: Integer; var ADone: Boolean);
begin
if AButtonIndex = NBDI_INSERT then
begin
cxGridDBTableView2.ViewData.Records[0].Values[4] := edimportecita.Text;
cxGridDBTableView2IMPORTE.Caption := edimportecita.Text;
cxGridDBTableView2IMPORTE.EditValue := edimportecita.Text;
cxGridDBTableView2IMPORTE.DataBinding.Field.Value := cdcg.FieldValues['importecitas'];
cdsc.FieldValues['importe'] := cdcg.FieldValues['importecitas'];
end;
end;
Segundo
procedure TfmEstadoCuenta.cdSCBeforeInsert(DataSet: TDataSet);
begin
if (cdsc.State = dsinsert) then
begin
cdsc.FieldValues['importe'] := cdcg.FieldValues['importecitas'];
cxGridDBTableView2IMPORTE.DataBinding.Field.Value := cdcg.FieldValues['importecitas'];
cdsc.FieldValues['fecha'] := date;
cxGridDBTableView2FECHA.DataBinding.ValueType := datetostr(date);
cxGridDBTableView2IMPORTE.Caption := edimportecita.Text;
cxGridDBTableView2.ViewData.Records[0].Values[2]:= edimportecita.Text;
end;
end;
de cada forma pero ninguna me ha dado resultado, ya busque algúnos ejemplos y con ellos hice lo anterior pero no le he dado al clavo les agradeceria cualquier ayuda, gracias por su tiempo.:D
Primero:
pprocedure TfmEstadoCuenta.cxNavigator1ButtonsButtonClick(Sender: TObject;
AButtonIndex: Integer; var ADone: Boolean);
begin
if AButtonIndex = NBDI_INSERT then
begin
cxGridDBTableView2.ViewData.Records[0].Values[4] := edimportecita.Text;
cxGridDBTableView2IMPORTE.Caption := edimportecita.Text;
cxGridDBTableView2IMPORTE.EditValue := edimportecita.Text;
cxGridDBTableView2IMPORTE.DataBinding.Field.Value := cdcg.FieldValues['importecitas'];
cdsc.FieldValues['importe'] := cdcg.FieldValues['importecitas'];
end;
end;
Segundo
procedure TfmEstadoCuenta.cdSCBeforeInsert(DataSet: TDataSet);
begin
if (cdsc.State = dsinsert) then
begin
cdsc.FieldValues['importe'] := cdcg.FieldValues['importecitas'];
cxGridDBTableView2IMPORTE.DataBinding.Field.Value := cdcg.FieldValues['importecitas'];
cdsc.FieldValues['fecha'] := date;
cxGridDBTableView2FECHA.DataBinding.ValueType := datetostr(date);
cxGridDBTableView2IMPORTE.Caption := edimportecita.Text;
cxGridDBTableView2.ViewData.Records[0].Values[2]:= edimportecita.Text;
end;
end;
de cada forma pero ninguna me ha dado resultado, ya busque algúnos ejemplos y con ellos hice lo anterior pero no le he dado al clavo les agradeceria cualquier ayuda, gracias por su tiempo.:D