Pido disculpas de antemano por revivir este tema y que basicamente lo entiende Caral, pero al intentar recrear lo que el realizo en un nuevo formulario, me tira el siguiente error
"List index out of bounds (4)"
cuando cambio el combobox de producto a servicio, agrego la codificacion del combobox, por si esta ahi el error.
Código Delphi
[-]procedure TForm14.ComboBox1Change(Sender: TObject);
begin
if combobox1.Text = 'Productos' then
begin
datasource5.DataSet:= Table4;
Dbgrid2.Columns[0].FieldName:= 'Cod_prod';
Dbgrid2.Columns[0].Title.caption:= 'Cod.prod';
Dbgrid2.Columns[0].Width:= 60;
Dbgrid2.Columns[2].FieldName:= 'Nombre';
Dbgrid2.Columns[2].Title.caption:= 'Producto';
Dbgrid2.Columns[4].Visible:= True;
Dbgrid2.Columns[5].Visible:= True;
Dbgrid2.Columns[4].Width:= 180;
Dbgrid2.Columns[2].Width:= 150;
Dbgrid2.Columns[4].FieldName:= 'Descripcion';
Dbgrid2.Columns[4].Title.caption:= 'Descripcion';
Dbgrid2.Columns[5].FieldName:= 'ImpVent';
Dbgrid2.Columns[5].Title.caption:= 'Import.Venta';
end;
if combobox1.Text = 'Servicios' then
begin
datasource5.DataSet:= Table5;
Dbgrid2.Columns[0].FieldName:= 'Cod_servcio';
Dbgrid2.Columns[0].Title.caption:= 'Cod.servicio';
Dbgrid2.Columns[2].FieldName:= 'Servicio';
Dbgrid2.Columns[2].Title.caption:= 'Servicio';
Dbgrid2.Columns[3].FieldName:= 'ImpServ';
Dbgrid2.Columns[3].Title.caption:= 'ImporteServ.';
Dbgrid2.Columns[4].Visible:= False;
Dbgrid2.Columns[5].Visible:= False;
end;
end;
Muchas gracias.