窗体应用程序,放了个treeview控件,并设置了节点显示checkbox,现在是想取所有勾选节点的checkbox的node.text,并把这些text存入一个数组,请教方法(不懂要遍历哪个),
因为是窗体应用程序的,又不能用js去做,请大虾们指教下,谢谢~~
因为是窗体应用程序的,又不能用js去做,请大虾们指教下,谢谢~~
解决方案 »
- 唉,为什么不对?连接Oracle
- 数据连接层怎么写啊?
- 请问大家哪里有ASP.NET的商城界面模版下载?
- 公文流转中的 公文模板自定义 用什么形式来做 怎么做,请给个解决方法多谢 给80分
- js新手 各位高手指点菜鸟一下
- 错误提示 : 需要更新可能的query。
- 怎样去掉datatime类型数据后面的秒数
- 菜鸟提问.寻高手加QQ:'解决,我都想老一天.
- DataGrid下的单元格换行问题,不要单元换行,在线等待!!!
- 图片处理,上传大小超过500K的图片就出现内存不足。。。
- DropDownList1的值不能重复
- Page.Request.QueryString["T"] == "E"是什么意思
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server"> void Button_Click(Object sender, EventArgs e)
{ if(LinksTreeView.CheckedNodes.Count > 0)
{ // Clear the message label.
Message.Text = "You selected: <br /><br />"; // Iterate through the CheckedNodes collection and display the selected nodes.
foreach (TreeNode node in LinksTreeView.CheckedNodes)
{ Message.Text += node.Text + "<br />"; } } else
{ Message.Text = "No items selected."; } }</script><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>TreeView ShowCheckBoxes Example</title>
</head>
<body>
<form id="form1" runat="server"> <h3>TreeView ShowCheckBoxes Example</h3> <!-- Set the ShowCheckBoxes property declaratively. -->
<!-- Because the ShowCheckBoxes property uses a flag -->
<!-- enumeration, you can combine multiple values by -->
<!-- using the bitwise OR operator. In declarative -->
<!-- syntax, this is done using a comma separated -->
<!-- list. -->
<asp:TreeView id="LinksTreeView"
Font-Names= "Arial"
ForeColor="Blue"
ExpandDepth="2"
ShowCheckBoxes="Parent,Leaf"
runat="server"> <LevelStyles> <asp:TreeNodeStyle ChildNodesPadding="10"
Font-Bold="true"
Font-Size="12pt"
ForeColor="DarkGreen"/>
<asp:TreeNodeStyle ChildNodesPadding="5"
Font-Bold="true"
Font-Size="10pt"/>
<asp:TreeNodeStyle ChildNodesPadding="5"
Font-UnderLine="true"
Font-Size="10pt"/>
<asp:TreeNodeStyle ChildNodesPadding="10"
Font-Size="8pt"/> </LevelStyles> <Nodes> <asp:TreeNode Text="Table of Contents"
SelectAction="None"> <asp:TreeNode Text="Chapter One"> <asp:TreeNode Text="Section 1.0"> <asp:TreeNode Text="Topic 1.0.1"/>
<asp:TreeNode Text="Topic 1.0.2"/>
<asp:TreeNode Text="Topic 1.0.3"/> </asp:TreeNode> <asp:TreeNode Text="Section 1.1"> <asp:TreeNode Text="Topic 1.1.1"/>
<asp:TreeNode Text="Topic 1.1.2"/>
<asp:TreeNode Text="Topic 1.1.3"/>
<asp:TreeNode Text="Topic 1.1.4"/> </asp:TreeNode> </asp:TreeNode> <asp:TreeNode Text="Chapter Two"> <asp:TreeNode Text="Section 2.0"> <asp:TreeNode Text="Topic 2.0.1"/>
<asp:TreeNode Text="Topic 2.0.2"/> </asp:TreeNode> </asp:TreeNode> </asp:TreeNode>
<asp:TreeNode Text="Appendix A" />
<asp:TreeNode Text="Appendix B" />
<asp:TreeNode Text="Appendix C" /> </Nodes> </asp:TreeView> <br /><br /> <asp:Button id="Submit"
Text="Select Items"
OnClick="Button_Click"
runat="server"/> <br /><br /> <asp:Label id="Message"
runat="server"/> </form>
</body>
</html>
ms-help://MS.MSDNQTR.v90.en/dtsref9mref/html/d1ee7e45-80a0-a249-8235-2bc7263fd018.htm
List<string> checkedList=new List<string>();//存放checked节点
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
{
if (e.Node.Checked)
{
checkedList.Add(e.Node.Name);
}
else
{
checkedList.Remove(e.Node.Name);
}
} private void button1_Click(object sender, EventArgs e)
{
string[] checkedSet = checkedList.ToArray(); //取得checked数组
}