How to remove col boxes from a tablebox?<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />I'm using col boxes inside of table boxes to contain buttons. Very convenient way to have buttons, checkboxes, etc. inside a grid. The problem I'm having is that when I go to refresh the tablebox with new values the col boxes stubbornly hold on to their old values.
The code below demonstrates the behavior:
old_nr = 0;
nw = new window("Test col box removal",
hlistbox(,
textbox("Enter # rows: "),
neb = number edit box(),
),
button box("Refresh rows",
for (i = old_nr, i > 0, i--,
tbl_box << delete row(i);
);
c1_list = {};
n1_list = {};
cb_list = {};
nr = neb << get;
old_nr = nr;
for (i = 1, i <= nr, i++,
c1_list[i] = char(i);
n1_list[i] = i;
cb << append(button box(char(i)));
);
c1 << set values(c1_list);
n1 << set(n1_list);
),
tbl_box = table box(
c1 = string col box("C1", {}),
n1 = number col box("N1", {}),
cb = col box("CB", {}),
),
);
Re: How to remove col boxes from a tablebox?Thanks MS that's one wrinkle I didn't try. The COL BOX object doesn't behave the same way as a string col box or number col box
Re: How to remove col boxes from a tablebox?Seems to be easiest to delete the old Col Box() entirely and append a new one for each update.
Does this behave the way you want?
nw = New Window("Test col box removal",
H List Box(, Text Box("Enter # rows: "), neb = Number Edit Box(), ),
Button Box("Refresh rows",
c1_list = {};
n1_list = {};
cb_expr = Expr(Col Box("CB"));
nr = neb << get;
For(i = 1, i <= nr, i++,
c1_list[i] = Char(i);
n1_list[i] = i;
Insert Into(cb_expr, Button Box(Char(i)));
);
c1 << set values(c1_list);
n1 << set(n1_list);
cb << delete;
tbl_box << append(cb = cb_expr);
),
tbl_box = Table Box(c1 = String Col Box("C1", {}), n1 = Number Col Box("N1", {}), cb = Col Box("CB")),
);