我现在已经生成了一个ListView格式如下:
通道 状态 时间
0001 空闲 17:05
0002 忙碌 20:24
0003 未知 00:00
.............
我现在想修改其中的一条记录,比如0001我想改成忙碌,然后刷新对应的这条记录,其他记录不变,我用的是vsReport,有没有方法能够局部刷新,我现在记录比较多,通过socket来接受另外的程序发过来的消息,我可以得到我要更新的消息的结构,如:0001 忙碌 13:03,我根据0001找到对应的记录更新,当着条记录更新就自动刷新该条记录,最好能给点代码参考,谢谢!
通道 状态 时间
0001 空闲 17:05
0002 忙碌 20:24
0003 未知 00:00
.............
我现在想修改其中的一条记录,比如0001我想改成忙碌,然后刷新对应的这条记录,其他记录不变,我用的是vsReport,有没有方法能够局部刷新,我现在记录比较多,通过socket来接受另外的程序发过来的消息,我可以得到我要更新的消息的结构,如:0001 忙碌 13:03,我根据0001找到对应的记录更新,当着条记录更新就自动刷新该条记录,最好能给点代码参考,谢谢!
Items[2].SubItems.Strings[0] := xx;
Items[3].SubItems.Strings[0] := xx;
......
ListView不能实现吗?Virtual Listview没用过啊
Items[2].SubItems.Strings[0] := xx;
Items[3].SubItems.Strings[0] := xx;
......
能不能写详细点
begin
Items[1].SubItems.Strings[0] := xx;
Items[2].SubItems.Strings[0] := xx;
Items[3].SubItems.Strings[0] := xx;end;
begin
Items[1].SubItems.Strings[0] := xx;
Items[2].SubItems.Strings[0] := xx;
Items[3].SubItems.Strings[0] := xx;end;
界面里面的这条记录会自动更新吗?还有我知道0001怎么对应到Items[x]上面?
i:横坐标位置,j纵坐标位置,不过I的第一列不是Items[i].SubItems.Strings[0],而是Items[i].Caption
"呵呵。Virtual Listview 还是ListView.OwnerData := True;在OnData事件中写入相应代码.
"
ListView中用OwnerData := True;在OnData事件中写入相应代码.可以吗,我不是在界面上面修改值,我是程序内部值改变了在界面上面刷新显示.还有什么好方法吗?我都试试看,可以的话就揭贴了/
ChannelNo: string;
Status: string;
Time: string;
end;
PTChannelStatus = ^TChannelStatus; TForm1 = class(TForm)
ListView: TListView;
ButtonNew: TButton;
ButtonUpdate: TButton;
procedure ListViewData(Sender: TObject; Item: TListItem);
procedure FormCreate(Sender: TObject);
procedure ButtonNewClick(Sender: TObject);
procedure ButtonUpdateClick(Sender: TObject);
private
FList: TList;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ListViewData(Sender: TObject; Item: TListItem);
begin
Item.Caption := PTChannelStatus(FList.Items[Item.Index]).ChannelNo;
Item.SubItems.Add(PTChannelStatus(FList.Items[Item.Index]).Status);
Item.SubItems.Add(PTChannelStatus(FList.Items[Item.Index]).Time);
end;procedure TForm1.FormCreate(Sender: TObject);
var
Idx: Integer;
begin
FList := TList.Create;
ListView.DoubleBuffered := True;
with ListView.Columns.Add do
begin
Caption := '通道';
Width := 150;
end;
with ListView.Columns.Add do
begin
Caption := '状态';
Width := 150;
end;
with ListView.Columns.Add do
begin
Caption := '时间';
Width := 150;
end;
end;procedure TForm1.ButtonNewClick(Sender: TObject);
var
_TChannelStatus: array[0..999] of PTChannelStatus;
Idx: Integer;
begin
for Idx := 0 to 999 do
begin
New(_TChannelStatus[Idx]);
_TChannelStatus[Idx].ChannelNo := '000'+Trim(IntToStr(Idx+1));
_TChannelStatus[Idx].Status := '空闲';
_TChannelStatus[Idx].Time := FormatDateTime('HH:MMMM:SS', Now);
FList.Add(_TChannelStatus[Idx]);
end;
ListView.Items.Count := FList.Count;
end;procedure TForm1.ButtonUpdateClick(Sender: TObject);
begin
PTChannelStatus(FList.Items[3]).Status := '忙碌';
PTChannelStatus(FList.Items[3]).Time := FormatDateTime('HH:MMMM:SS', Now);
ListView.Refresh;
end;
至于在实际应用中你的记录集如何实时修改,你根据你的实际情况写吧。