加载图像会使列表框&文本框闪烁一次 [英] Loading an image makes listbox & textboxes blink once

查看:43
本文介绍了加载图像会使列表框&文本框闪烁一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Access 2016中,我有一个带有列表框的表单,以及一个图像控件,名为imgFrame .

In Access 2016 I have a form with a listbox, and an Image Control named imgFrame.

在列表框中单击文件名时,将显示图像.列表框的 Click 事件的代码为: imgFrame.Picture ="c:\ path \ filename.jpg"

When a filename is clicked in the listbox, the image is displayed. The code for the listbox's Click event is: imgFrame.Picture = "c:\path\filename.jpg"

此行每次运行时,图像都会加载,但是图像控件(以及表单上的任何文本框)(命令按钮不闪烁.)

Any time this line runs, the image loads but the Image Control (and any text boxes on the form) once. (The command button does not blink.)

屏幕截图(慢动作)

我尝试使用Application.Echo进行填充,如下所示:

I tried padding with Application.Echo like this:

Sub showImg_pic(fName)
    Application.Echo False
    imgFrame.Picture = fName
    DoEvents
    Application.Echo True
End Sub

并以相同的方式尝试了 imgFrame.Visible ,但没有发现任何区别.

and experimented with imgFrame.Visible in the same way but saw no difference.

推荐答案

代码设置将ControlSource属性添加到Image控件之前,Access 2003需要使用Picture属性.

Code setting Picture property was required back with Access 2003 before ControlSource property was added to the Image control.

我从未使用过Picture属性.我使用ControlSource属性在Image控件中动态加载图像.它可以引用保存图像文件的附件类型字段,但嵌入文件可以大大增加数据库大小,更快地达到2GB Access文件大小限制.因此,还可以引用具有用于外部位置的完整图像路径或部分路径的文本字段,并使用表达式构造完整路径.没有VBA代码.没有眨眼.

I have never used the Picture property. I use ControlSource property to dynamically load images in Image control. It can reference an attachment type field that holds image files but embedding files can substantially increase db size, more quickly reaching 2GB Access file size limit. So, can also reference a text field that has full image path for external location, or partial path and use an expression to construct full path. No VBA code. No blinking.

="C:\您的文件夹路径\"&[列表框名称]

使用任何字段来构造图像文件名:
="C:\您的文件夹路径\"&[EmployeeID]&".jpg"

Use any field to construct image filename:
="C:\your folder path\" & [EmployeeID] & ".jpg"

如果图像位于db旁边的文件夹中:
= CurrentProject.Path&"\ Images \"&[列表框名称]

If the images are in a folder next to the db:
=CurrentProject.Path & "\Images\" & [listbox name]

如果图像位于中央服务器位置,请使用UNC路径:
="\\服务器名称\ path \ Images \"&[列表框名称]

If the images are in central server location, use UNC path:
="\\servername\path\Images\" & [listbox name]

这篇关于加载图像会使列表框&文本框闪烁一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆