如何自定义列表视图以显示不同的背景颜色,如下图所示?
我的listview绑定到数据源(Livebindng).我想使用颜色字段来设置我的背景颜色.
我这样定制了我的观点:
文本项绑定到数据源,但无法将我的位图绑定到"颜色"字段.
我已经填充了listview ActivesUpdateObjects事件,但这并不是因为当数据源记录更新时位图没有改变!
procedure TfrmMain.lvTachesActivesUpdateObjects(const Sender: TObject;
const AItem: TListViewItem);
begin
SetItemColor(AItem);
end;
procedure TfrmMain.SetItemColor(const AItem: TListViewItem; const UpdateColor:
Boolean = False);
var
LObject: TListItemImage;
VC: TColor;
begin
LObject := AItem.Objects.FindObjectT<TListItemImage>('Couleur');
VC:= dtmMain.qrTaches.FieldByName('couleur').AsInteger;
if LObject.Bitmap = nil then
begin
LObject.Bitmap := FMX.Graphics.TBitmap.Create(10,240);
LObject.Bitmap.Clear(VC);
end else if UpdateColor then LObject.Bitmap.Clear(VC);
end;
Run Code Online (Sandbox Code Playgroud)
还有更好的方法吗?我也在寻找o使用样式但是看起来(或者我没有找到)itemlistview无法应用样式!
Ps:Firemonkey/Windows/Delphi Berlin XE10.1
在我的应用程序中,我的用户可以将文件(pdf/xls/doc)导入表或将它们导出到文件夹.现在我想直接打开这些文件.
到目前为止,我能够: - 获得一个唯一的名称 - 将blob文件保存到生成的文件中 - 打开它
问题是我不知道如何删除(或更新)文件,之后用户将关闭该文件.
如果有人可以帮助我,我会很高兴:)
这是我的代码的快照:
procedure OpenTemporaryFile(AFileExtension: String; AKey: Integer;
AMyConnection: TMyConnection);
Var
qrDocuments : TMyQuery ;
TmpName,ExtName: string;
TempFileName: TFileStream;
begin
//Generate an unique tmp file located into user temp folder
TmpName:= FileGetTempName('~SI');
ExtName:= ChangeFileExt(TmpName, AFileExtension);
//Change files extension so that Shellexecute will be able to open the file
RenameFile(TmpName,ExtName );
//Creating the FileStream (data is fetched from an blob field)
TempFileName := TFileStream.Create(ExtName, fmOpenReadWrite );
qrDocuments := TMyQuery.create(nil);
try
qrDocuments.Connection := AMyConnection; …Run Code Online (Sandbox Code Playgroud) 为什么Windows在通过线程下载文件时抛出防火墙警报而不是从主线程下载时?两个代码都是一样的!
我怎么能摆脱这个?(我的用户只有"权限用户").