Tableview categories on the fly


I'm trying to figure out how to add categories in runtime at your Tableview component, this is because I need to fill the categories based on a different results.


For X := Low(ResultadoProductos) to High(ResultadoProductos) do
If Productos.Categories.ItemIndexById(ResultadoProductos[X].Unidad) = -1 then
Productos.Categories.Add.Id := ResultadoProductos[X].Unidad;
Productos.Categories.ItemById(ResultadoProductos[X].Unidad).Caption := ResultadoProductos[X].UnidadMedida;                         

Once the categories are complete with all possible values, then I get all details and assigned each record to specific category

DetalleCFDI.CategoryID := ResultadoProductos[X].Unidad;

However this is not working, apparently your tableview only works with the categories fill in design time why?

did you use BeginUpdate and EndUpdate wrappers around the code?