//ListViewOnClick事件 begin if ListView.Selected<>nil then begin if LIstView.Selected.subItem[0]='是' then ListView.Selected.subItem[0]:='否' else ListView.Selected.subItem[0]:='是'; end;end;
to argl521 是否合法那 不好使啊
procedure TForm1.ListView1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var vListItem: TListItem; vWidth: Integer; i: Integer; begin ListView1.ReadOnly := True; ListView1.RowSelect := True; case Button of mbLeft: begin vListItem := listview1.GetItemAt(x,y); if vListItem = nil then Exit; vWidth := 0; for i := 0 to ListView1.Columns.Count - 1 do begin if (x >= vWidth) and (x < vWidth + ListView1.Column[i].Width) then if (i > 0) and (vListItem.SubItems[i-1] = '是') then begin vListItem.SubItems[i-1] := '否'; Exit; end; Inc(vWidth, ListView1.Column[i].Width); end; end; end; end;
to zhongme_007 你这个确实很管用但是我不明白他的意识 能否讲讲 什么原理? 让新人也明白点嘛 哈
begin
if ListView.Selected<>nil then
begin
if LIstView.Selected.subItem[0]='是' then
ListView.Selected.subItem[0]:='否'
else
ListView.Selected.subItem[0]:='是';
end;end;
Shift: TShiftState; X, Y: Integer);
var
vListItem: TListItem;
vWidth: Integer;
i: Integer;
begin
ListView1.ReadOnly := True;
ListView1.RowSelect := True;
case Button of
mbLeft:
begin
vListItem := listview1.GetItemAt(x,y);
if vListItem = nil then
Exit;
vWidth := 0;
for i := 0 to ListView1.Columns.Count - 1 do
begin
if (x >= vWidth) and (x < vWidth + ListView1.Column[i].Width) then
if (i > 0) and (vListItem.SubItems[i-1] = '是') then
begin
vListItem.SubItems[i-1] := '否';
Exit;
end;
Inc(vWidth, ListView1.Column[i].Width);
end;
end;
end;
end;