如何在Windows应用程序中从XML文件设置按钮的图像属性. [英] How to set image property of button from XML file in windows application.

查看:59
本文介绍了如何在Windows应用程序中从XML文件设置按钮的图像属性.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个关于从XML文件读取按钮的图像属性的查询.

我使用System.Windows.Forms.Controls读取XML文件以生成屏幕.读取XML文件并使用Reflection
设置属性
下面给出了它的示例表示

Hi,

I have a query regarding reading Image Property for button from a XML file.

I read XML files to Generate Screens using System.Windows.Forms.Controls. The XML file is read and properties are set using Reflection

A sample representation of it is given below

<Control type="System.Windows.Forms.Button, System.Windows.Forms,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="Button2">
<Property name="TabIndex" value="6"></Property>
<Property name="Size" value="75, 23"></Property>
<Property name="Name" value="Button2"></Property>
<Property name="UseVisualStyleBackColor" value="true"></Property>
<Property name="Text" value="Exit"></Property>
<Property name="Location" value="106, 170"></Property>


是否可以指定如下所示的Image属性


Is it possible to specify the Image Property as Given Below

<Property name="Image" value="C:\Data\Image.bmp"></Property>


映像名称如何在运行时读取并绑定到动态生成的程序集.

请指教?

[edit]已添加代码块-OriginalGriff [/edit]


How can the Image Name read at run time and binded to dynamically generated assembly.

Please advice?

[edit]Code blocks added - OriginalGriff[/edit]

推荐答案

您是否正在询问如何读取value属性?如果是这样,这是令人惊讶的,因为您的核心应用程序本身会从XML生成UI.因此,您确定应该已经有一个XML解析器并且可以使用了吗?如果不是,那么如何解析XML或打算如何读取XML?

现在,如果我误解了,您已经解析了所有XML并准备使用它们,但是您想知道是否可以在控件上设置图像,那么它实际上取决于控件.许多控件确实支持直接将图像设置为背景,但并非全部都支持.因此,对于某些控件,除非您使用已通过image属性增强的派生/自定义控件,否则您将无法执行此操作.
Are you asking how to read the value attribute? If so that''s surprising since your core application itself generates UI from XML. So surely you should already have an XML parser in place and all ready to use? If not, then how are you parsing the XML or how do you plan to read in the XML?

Now if I misunderstood and you have the XML all parsed out and ready to use, but you are wondering if you can set images on controls, then it really depends on the controls. Many controls do support setting an image as background directly, but not all do. So for some controls you won''t be able to do this unless you use derived/custom controls that have been enhanced with an image property.


这篇关于如何在Windows应用程序中从XML文件设置按钮的图像属性.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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