如何将列表项绑定到列表框以进行扩展并最小化类似节点 [英] How to bind list items to list box for expend and minimize like nodes

查看:60
本文介绍了如何将列表项绑定到列表框以进行扩展并最小化类似节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在win表单中使用最大化和最小化按钮来绑定List项目中的子项c#,我只是将listitem与多列绑定,这是我的代码



我尝试过:



How to bind sub items in List item in win forms with maximize and minimize buttons c#, i have just bind listitem with multiple columns,here is my code

What I have tried:

listView2.Columns.Add("Id", 245, HorizontalAlignment.Left);
listView2.Columns.Add("Name", 241, HorizontalAlignment.Left);
listView2.Columns.Add("Mobile Number", 245, HorizontalAlignment.Left);
listView2.Columns.Add("ASET", 245, HorizontalAlignment.Left);
// Getting the data to a datasource
SqlConnection con = new SqlConnection("Data Source=192.168.1.101\\SQLEXPRESS;Initial Catalog=algen_db;User ID=vipl-user;Password=vipl-user!@#$%");
listView2.Items.Clear();
SqlDataAdapter adp = new SqlDataAdapter("select acdesc,acno,speactype,acremarks from chartaccount where ParentAcNo is null order by AcNo", con);
DataTable dt = new DataTable();
adp.Fill(dt);

string[] Str = new string[4];
ListViewItem newItm;
foreach (DataRow dataRow in dt.Rows)
{
    Str[0] = dataRow["acdesc"].ToString();
    Str[1] = dataRow["acno"].ToString();
    Str[2] = dataRow["speactype"].ToString();
    Str[3] = dataRow["acremarks"].ToString();
    newItm = new ListViewItem(Str);
    listView2.Items.Add(newItm);              
    newItm.SubItems.Add("Aaa");
}

推荐答案

%);
listView2.Items.Clear();
SqlDataAdapter adp = new SqlDataAdapter( select acdesc来自chartaccount的acno,speactype,acremarks,其中ParentAcNo是由AcNo,con)的空订单;
DataTable dt = new DataTable();
adp.Fill(dt);

string [] Str = new string [ 4 ];
ListViewItem newItm;
foreach (DataRow dataRow in dt.Rows)
{
Str [ 0 ] = dataRow [ acdesc]。ToString() ;
Str [ 1 ] = dataRow [ acno]。ToString();
Str [ 2 ] = dataRow [ 。speactype]的ToString();
Str [ 3 ] = dataRow [ acremarks]的ToString();
newItm = new ListViewItem(Str);
listView2.Items.Add(newItm);
newItm.SubItems.Add( Aaa);
}
%"); listView2.Items.Clear(); SqlDataAdapter adp = new SqlDataAdapter("select acdesc,acno,speactype,acremarks from chartaccount where ParentAcNo is null order by AcNo", con); DataTable dt = new DataTable(); adp.Fill(dt); string[] Str = new string[4]; ListViewItem newItm; foreach (DataRow dataRow in dt.Rows) { Str[0] = dataRow["acdesc"].ToString(); Str[1] = dataRow["acno"].ToString(); Str[2] = dataRow["speactype"].ToString(); Str[3] = dataRow["acremarks"].ToString(); newItm = new ListViewItem(Str); listView2.Items.Add(newItm); newItm.SubItems.Add("Aaa"); }


这是 - 使用可折叠组扩展C#ListView(第一部分) [ ^ ]。


这篇关于如何将列表项绑定到列表框以进行扩展并最小化类似节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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