获取菜单项值 [英] GET MENU ITEM VALUE

查看:56
本文介绍了获取菜单项值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我如何获得菜单项目的实际对象[不是索引]。是有过滤器还是我可以使用的东西。我现在已经打了4个小时,我最终得到了相同的结果


这就是我做的事情....

昏暗XmlDocument As New System.Xml.XmlDocument


XmlDocument.LoadXml(p_wsFormMenu.GetMenuItemData.O uterXml)


with p_aMenu


''找到正确的节点迭代。


Dim Node As System.Xml.XmlNode


For Each节点在XmlDocument.Item(" loadArray")中


如果Node.Name =" add"然后


Dim formName As String = Node.Attributes.GetNamedItem(" key")。Value()


Dim menuOption As Object = Node.Attributes.GetNamedItem(" value")。值


''填充数组


.Add(formName,menuOption)< ; ---这家伙需要是实际的对象而不是字符串。我从XML文件中获取值,但我需要以某种方式比较并返回基于字符串的实际菜单对象。如果有人可以帮助我会很感激。


结束如果


下一个节点


结束

-

MARLON LA ROSE

CAN ANYONE TELL ME HOW I GET THE ACTUAL OBJECT [NOT THE INDEX] OF A MENU ITEM. IS THERE A FILTER OR SOMETHING THAT I CAN USE. I HAVE BEEN FIGHTING WITH THIS FOR ABOUT 4 HOURS NOW AND I END UP GETTING THE SAME RESULTS

THIS IS WHAT I AM DOING ....
Dim XmlDocument As New System.Xml.XmlDocument

XmlDocument.LoadXml(p_wsFormMenu.GetMenuItemData.O uterXml)

With p_aMenu

'' Find the right node iterate through.

Dim Node As System.Xml.XmlNode

For Each Node In XmlDocument.Item("loadArray")

If Node.Name = "add" Then

Dim formName As String = Node.Attributes.GetNamedItem("key").Value()

Dim menuOption As Object = Node.Attributes.GetNamedItem("value").Value

''Fill the array

.Add(formName, menuOption) <--- this guy needs to be the actual object and not a string. I am getting the value from an XML file but I need to somehow compare and return the actual menu object based on the string. if anyone can help I would appreciate it.

End If

Next Node

End With
--
MARLON LA ROSE

推荐答案

XML只是文字,你必须记住。但是,您可以通过.Name属性循环遍历控件集合以查找相关菜单项。


然后比较并返回实际控件。

MARLON LA ROSE <毫升***** @ email.uophx.edu>在留言新闻中写道:%2 **************** @ TK2MSFTNGP12.phx.gbl ...

任何人都可以告诉我如何获得实际对象菜单项目的[不是索引]。是有过滤器还是我可以使用的东西。我现在已经打了4个小时,我最终得到了相同的结果


这就是我做的事情....

昏暗XmlDocument As New System.Xml.XmlDocument


XmlDocument.LoadXml(p_wsFormMenu.GetMenuItemData.O uterXml)


with p_aMenu


''找到正确的节点迭代。


Dim Node As System.Xml.XmlNode


For Each节点在XmlDocument.Item(" loadArray")中


如果Node.Name =" add"然后


Dim formName As String = Node.Attributes.GetNamedItem(" key")。Value()


Dim menuOption As Object = Node.Attributes.GetNamedItem(" value")。值


''填充数组


.Add(formName,menuOption)< ; ---这家伙需要是实际的对象而不是字符串。我从XML文件中获取值,但我需要以某种方式比较并返回基于字符串的实际菜单对象。如果有人可以帮助我会很感激。


结束如果


下一个节点


结束

-

MARLON LA ROSE
XML is just text, you gotta remember that. However, you can cycle through your controls collection recursivly to find the menu item in question via the .Name property.

then compare that and return the actual control.
"MARLON LA ROSE" <ml*****@email.uophx.edu> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
CAN ANYONE TELL ME HOW I GET THE ACTUAL OBJECT [NOT THE INDEX] OF A MENU ITEM. IS THERE A FILTER OR SOMETHING THAT I CAN USE. I HAVE BEEN FIGHTING WITH THIS FOR ABOUT 4 HOURS NOW AND I END UP GETTING THE SAME RESULTS

THIS IS WHAT I AM DOING ....
Dim XmlDocument As New System.Xml.XmlDocument

XmlDocument.LoadXml(p_wsFormMenu.GetMenuItemData.O uterXml)

With p_aMenu

'' Find the right node iterate through.

Dim Node As System.Xml.XmlNode

For Each Node In XmlDocument.Item("loadArray")

If Node.Name = "add" Then

Dim formName As String = Node.Attributes.GetNamedItem("key").Value()

Dim menuOption As Object = Node.Attributes.GetNamedItem("value").Value

''Fill the array

.Add(formName, menuOption) <--- this guy needs to be the actual object and not a string. I am getting the value from an XML file but I need to somehow compare and return the actual menu object based on the string. if anyone can help I would appreciate it.

End If

Next Node

End With
--
MARLON LA ROSE


XML只是文字,你必须记住。但是,您可以通过.Name属性循环遍历控件集合以查找相关菜单项。


然后比较并返回实际控件。

MARLON LA ROSE <毫升***** @ email.uophx.edu>在留言新闻中写道:%2 **************** @ TK2MSFTNGP12.phx.gbl ...

任何人都可以告诉我如何获得实际对象菜单项目的[不是索引]。是有过滤器还是我可以使用的东西。我现在已经打了4个小时,我最终得到了相同的结果


这就是我做的事情....

昏暗XmlDocument As New System.Xml.XmlDocument


XmlDocument.LoadXml(p_wsFormMenu.GetMenuItemData.O uterXml)


with p_aMenu


''找到正确的节点迭代。


Dim Node As System.Xml.XmlNode


For Each节点在XmlDocument.Item(" loadArray")中


如果Node.Name =" add"然后


Dim formName As String = Node.Attributes.GetNamedItem(" key")。Value()


Dim menuOption As Object = Node.Attributes.GetNamedItem(" value")。值


''填充数组


.Add(formName,menuOption)< ; ---这家伙需要是实际的对象而不是字符串。我从XML文件中获取值,但我需要以某种方式比较并返回基于字符串的实际菜单对象。如果有人可以帮助我会很感激。


结束如果


下一个节点


结束

-

MARLON LA ROSE
XML is just text, you gotta remember that. However, you can cycle through your controls collection recursivly to find the menu item in question via the .Name property.

then compare that and return the actual control.
"MARLON LA ROSE" <ml*****@email.uophx.edu> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
CAN ANYONE TELL ME HOW I GET THE ACTUAL OBJECT [NOT THE INDEX] OF A MENU ITEM. IS THERE A FILTER OR SOMETHING THAT I CAN USE. I HAVE BEEN FIGHTING WITH THIS FOR ABOUT 4 HOURS NOW AND I END UP GETTING THE SAME RESULTS

THIS IS WHAT I AM DOING ....
Dim XmlDocument As New System.Xml.XmlDocument

XmlDocument.LoadXml(p_wsFormMenu.GetMenuItemData.O uterXml)

With p_aMenu

'' Find the right node iterate through.

Dim Node As System.Xml.XmlNode

For Each Node In XmlDocument.Item("loadArray")

If Node.Name = "add" Then

Dim formName As String = Node.Attributes.GetNamedItem("key").Value()

Dim menuOption As Object = Node.Attributes.GetNamedItem("value").Value

''Fill the array

.Add(formName, menuOption) <--- this guy needs to be the actual object and not a string. I am getting the value from an XML file but I need to somehow compare and return the actual menu object based on the string. if anyone can help I would appreciate it.

End If

Next Node

End With
--
MARLON LA ROSE


感谢您的回复 - 我知道XML是一个文本属性 - 但是,我看起来不可能在VB.net中找到任何允许我返回menuItem的name属性的功能,只是一个索引。有没有办法通过将它与从XML返回的字符串进行比较来返回实际的name属性?

-

MARLON LA ROSE

CJ Taylor <无**** @ blowgoats.com>在消息新闻中写道:10 ************* @ corp.supernews.com ...

XML只是文字,你必记得。但是,您可以通过.Name属性循环遍历控件集合以查找相关菜单项。


然后比较并返回实际控件。

MARLON LA ROSE <毫升***** @ email.uophx.edu>在留言新闻中写道:%2 **************** @ TK2MSFTNGP12.phx.gbl ...

任何人都可以告诉我如何获得实际对象菜单项目的[不是索引]。是有过滤器还是我可以使用的东西。我现在已经打了4个小时,我最终得到了相同的结果


这就是我做的事情....

昏暗XmlDocument As New System.Xml.XmlDocument


XmlDocument.LoadXml(p_wsFormMenu.GetMenuItemData.O uterXml)


with p_aMenu


''找到正确的节点迭代。


Dim Node As System.Xml.XmlNode


For Each节点在XmlDocument.Item(" loadArray")中


如果Node.Name =" add"然后


Dim formName As String = Node.Attributes.GetNamedItem(" key")。Value()


Dim menuOption As Object = Node.Attributes.GetNamedItem(" value")。值


''填充数组


.Add(formName,menuOption)< ; ---这家伙需要是实际的对象而不是字符串。我从XML文件中获取值,但我需要以某种方式比较并返回基于字符串的实际菜单对象。如果有人可以帮助我会很感激。


结束如果


下一个节点


结束

-

MARLON LA ROSE
Thanks for responding - I am aware that XML is a text property - however, I can''t seem to find any feature in VB.net that allows me to return the name property of the menuItem, just an index. Is there a way to return the actual name property by comparing it to the string returned form the XML?
--
MARLON LA ROSE
"CJ Taylor" <no****@blowgoats.com> wrote in message news:10*************@corp.supernews.com...
XML is just text, you gotta remember that. However, you can cycle through your controls collection recursivly to find the menu item in question via the .Name property.

then compare that and return the actual control.
"MARLON LA ROSE" <ml*****@email.uophx.edu> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
CAN ANYONE TELL ME HOW I GET THE ACTUAL OBJECT [NOT THE INDEX] OF A MENU ITEM. IS THERE A FILTER OR SOMETHING THAT I CAN USE. I HAVE BEEN FIGHTING WITH THIS FOR ABOUT 4 HOURS NOW AND I END UP GETTING THE SAME RESULTS

THIS IS WHAT I AM DOING ....
Dim XmlDocument As New System.Xml.XmlDocument

XmlDocument.LoadXml(p_wsFormMenu.GetMenuItemData.O uterXml)

With p_aMenu

'' Find the right node iterate through.

Dim Node As System.Xml.XmlNode

For Each Node In XmlDocument.Item("loadArray")

If Node.Name = "add" Then

Dim formName As String = Node.Attributes.GetNamedItem("key").Value()

Dim menuOption As Object = Node.Attributes.GetNamedItem("value").Value

''Fill the array

.Add(formName, menuOption) <--- this guy needs to be the actual object and not a string. I am getting the value from an XML file but I need to somehow compare and return the actual menu object based on the string. if anyone can help I would appreciate it.

End If

Next Node

End With
--
MARLON LA ROSE


这篇关于获取菜单项值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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