如何在XML节点上具有onClick() [英] How to have onClick() on XML nodes

查看:343
本文介绍了如何在XML节点上具有onClick()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在XML节点上应用某种"onClick"事件?具有以下内容:

桌子
测试
code123code
测试
测试
code1234code
测试
桌子

如果我将XML文件读入项目并在ListView中显示,是否可以向123添加单击"方法?

Is it possible to applying some sort of "onClick" event on the XML nodes? With the following:

tables
test
code123code
test
test
code1234code
test
tables

If I read the XML file into my project and display it in a ListView, can I add an "on click" method to 123?

private void listView1_ItemActivate(object sender, EventArgs e)
{ 
testBox1.Text = "test";
}

当我尝试上面的onClick方法时,当我单击123和1234时会显示测试,这是他们指定要与onClick方法一起使用的节点的一种方法.

When i try the onClick method above it displays test when i click on 123 and 1234, is their a way to specify the node you want the onClick method to work with.

推荐答案

您可以使用以下小型算法:

1-一一载入您的xml标记
2-检查标签名称是否为123,并将其放在某个控件上,并进行点击事件
3-如果名称不是123,则即使没有单击也将其添加到控件中


如此简单.
you can use this small algorithm:

1- load your xml tags one by one
2- check and see if the tag name is 123 put it on some control and make your click event
3- if the name isn''t 123 add it to the control without the click even


as simple as that.


如果使用WPF,则可以为每一行创建文本块.在带有123的文本块上,添加一个MouseUp事件.只需定义一个垂直方向的StackPanel并将其添加到堆栈面板即可.
比较简单的方法就是处理点击并检查文本.
If you use WPF, then you can create textblocks for each line. On the textblocks with the 123, add a MouseUp event. Just define a StackPanel with Vertical orientation and add them to the stackpanel.
Easier would be to just handle the click and check the text.


这篇关于如何在XML节点上具有onClick()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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