1个CheckListBox1和1个DBGRID
把DBGRID.Columns.Items[i].Visible=true 的Title.Caption 分别添加在CheckListBox1里面
var
i:integer;
begin
checklistbox1.Items.Clear;
for i:=0 to ehname.Columns.Count-1 do
begin
if ehname.Columns.Items[i].Visible=true then
CheckListBox1.Items.Add(ehname.Columns.Items[i].Title.Caption);
end;
for i:=0 to CheckListBox1.Items.Count-1 do
begin
CheckListBox1.Checked[i]:=true;
end;问题。。
怎么通过选择checklistbox1里的勾来调整 DBGRID的列可见和不可见
难点在于DBGRID里原先有几列的VISABLE=false的
把DBGRID.Columns.Items[i].Visible=true 的Title.Caption 分别添加在CheckListBox1里面
var
i:integer;
begin
checklistbox1.Items.Clear;
for i:=0 to ehname.Columns.Count-1 do
begin
if ehname.Columns.Items[i].Visible=true then
CheckListBox1.Items.Add(ehname.Columns.Items[i].Title.Caption);
end;
for i:=0 to CheckListBox1.Items.Count-1 do
begin
CheckListBox1.Checked[i]:=true;
end;问题。。
怎么通过选择checklistbox1里的勾来调整 DBGRID的列可见和不可见
难点在于DBGRID里原先有几列的VISABLE=false的
DBGrid.Columns[i].Visible:=CheckList1.Checked[i];
begin
CheckListBox1.Items.Add(ehname.Columns.Items[i].Title.Caption);
CheckListBox1.Checked[i] := ehname.Columns.Items[i].Visible;
end;
begin
for j:=0 to ehname.Columns.Count-1 do
begin
if ehname.Columns.Items[j].Title.Caption=CheckListBox1.Items.Strings[i]then
begin
ehname.Columns.Items[j].Visible:=CheckListBox1.Checked[i];
break;
end;
end;
end;