在C# winform 中的treeview 选中节点,获取其在数据库中的字段ID

在C# winform 中的treeview 选中节点,获取其在数据库中的字段ID,第1张

绑定时为节点添加Tag属性值

treeView1NodesAdd("管理部")Tag = treeID;

获取treeID

private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)

{

TreeNode node=treeView1SelectedNode;

treeID类型 treeID = (treeID类型) nodeTag;

}

FileStream fs1 = new FileStream(">

具体代码如下:请参考。

private static string GetAppConfig(string strKey)

{

foreach (string key in ConfigurationManagerAppSettings)

{

if (key == strKey)

{

return ConfigurationManagerAppSettings[strKey];

}

}

return null;

}

此段为获取指定配置节的代码,打开它的方法是按读取xml文件的方法。

XmlTextReader objXMLReader=new XmlTextReader(ServerMapPath("gradexml"));

string strNodeResult="";

XmlNodeType objNodeType;

while(objXMLReaderRead())

{

objNodeType =objXMLReaderNodeType;

swith(objNodeType)

{

case XmlNodeTypeXmlDeclaration:

//读取XML文件头

strNodeResult+="XML Declaration:<b>"+objXMLReaderName+""+objXMLReaderValue+"</b><br/>";

break;

case XmlNodeTypeElement:

//读取标签

strNodeResult+="Element:<b>"+objXMLReaderName+"</b><br/>";

break;

case XmlNodeTypeText:

//读取值

strNodeResult+=" -Value:<b>"+objXMLReaderValue+"</b><br/>";

break;

}

//判断该节点是否有属性

if(objXMLReaderAttributeCount>0)

{ //用循环判断完所有节点

while(objXMLReaderMoveToNextAttibute)

{ //取标签和值

strNodeResult+=" -Attribute:<b>"+objXMLReaderName+"</b> value:<b>"+objXMLReaderValue+"</b><br/>";

}

}

以上就是关于在C# winform 中的treeview 选中节点,获取其在数据库中字段ID全部的内容,包括:在C# winform 中的treeview 选中节点,获取其在数据库中的字段ID、winform读取apache/nginx配置、怎么打开winform项目下的app.config文件(以txt格式打开)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9677182.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-30
下一篇2023-04-30

发表评论

登录后才能评论

评论列表(0条)

    保存