求一COMBOX下拉Tree控件,在线等.立即结贴!~~ 求一拉TREE控件,不知道哪们仁兄有. 就是一combobox点击下拉TREE出来.谢谢.. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://download.microsoft.com/download/2/9/0/290e3bc2-a238-447f-ad45-98e590b3048b/TreeViewControl.msi可否? 楼上兄弟,那是1.1的.我可不想再同时安装1.1Framework,有2.0的不? http://blog.csdn.net/wzuomin/archive/2007/06/14/1652464.aspx lz可以直接使用我的那个ComboBoxTree.dll文件,可惜我也不怎么会改成c#的代码。http://download.csdn.net/source/357943 如果只需要点击出现一个TreeView,是不是就如http://blog.csdn.net/zhzuo/archive/2005/12/04/543278.aspxhttp://p.blog.csdn.net/images/p_blog_csdn_net/zhzuo/161762/o_image004.jpg上面的实现是使用一个TreeView来隐藏和显示来实现效果。主要代码如下,//设置目录选择框的位置this.treeViewCategory.Location = new Point(this.comboBoxCategory.Location.X,this.comboBoxCategory.Location.Y + this.comboBoxCategory.Size.Height);this.treeViewCategory.Size = new Size(this.comboBoxCategory.Size.Width,this.treeViewCategory.Height);事件处理程序, private void comboBoxCategory_DropDown(object sender, System.EventArgs e) { this.treeViewCategory.Select(); this.comboBoxCategory.DropDown -= new System.EventHandler(this.comboBoxCategory_DropDown); this.comboBoxCategory.DroppedDown = true; this.comboBoxCategory.DropDown += new System.EventHandler(this.comboBoxCategory_DropDown); //if( this.treeViewCategory.Visible == true ) //{ // return;//在显示TreeView的情况下 //} this.treeViewCategory.Visible = !this.treeViewCategory.Visible; } 不是递归么 private void TypeBind() { ListItem items = new ListItem(); items.Text = "无"; items.Value ="-1"; this.DropDownList1.Items.Add(items); //得到所有设备名称: DataSet ds = SqlHelper.ExecuteDataset(connstr, CommandType.Text, "select ID,Name,PID from SDTZ_EquipmentType"); dt = ds.Tables[0]; //第一层加载(ID为-1) DataRow[] drs = dt.Select("PID=-1"); for (int i = 0; i < drs.Length; i++) { string name = drs[i][1].ToString(); int id = Convert.ToInt32(drs[i][0]); this.DropDownList1.Items.Add(name); this.DropDownList1.Items[this.DropDownList1.Items.Count - 1].Value = id.ToString(); j = 0; LoadTree(id); } } int j = 0; //递归函数: private void LoadTree(int typeid) { string test = ""; DataRow[] drs = dt.Select("PID=" + typeid + ""); if (drs != null) { j++; for (int i = 0; i < j; i++) { test = test + "|-"; } for (int i = 0; i < drs.Length; i++) { this.DropDownList1.Items.Add(test + drs[i][1].ToString()); this.DropDownList1.Items[this.DropDownList1.Items.Count - 1].Value = drs[i][0].ToString(); LoadTree(Convert.ToInt32(drs[i][0])); } } } C#程序能不能设置为系统默认程序? c#使用AxAcroPDF控件时如何屏蔽鼠标右键及鼠标滚轮操作? 相对布局错位 【求助】如何防止数据库入录重复 请问怎样做多面体窗口呢? 求一个异步的 Socket(UDP方式)的通信程序 转告所有IT从业者!!! 如何区分表中重复记录数(非简单的distinct), 求高手 个 正则 如何在c#里面设置堆栈的大小?? .net framework和CLR的区别 datagrid 分页问题
可否?
可惜我也不怎么会改成c#的代码。
http://download.csdn.net/source/357943
http://blog.csdn.net/zhzuo/archive/2005/12/04/543278.aspx
http://p.blog.csdn.net/images/p_blog_csdn_net/zhzuo/161762/o_image004.jpg
上面的实现是使用一个TreeView来隐藏和显示来实现效果。
主要代码如下,
//设置目录选择框的位置
this.treeViewCategory.Location = new Point(this.comboBoxCategory.Location.X,this.comboBoxCategory.Location.Y + this.comboBoxCategory.Size.Height);
this.treeViewCategory.Size = new Size(this.comboBoxCategory.Size.Width,this.treeViewCategory.Height);事件处理程序,
private void comboBoxCategory_DropDown(object sender, System.EventArgs e)
{
this.treeViewCategory.Select();
this.comboBoxCategory.DropDown -= new System.EventHandler(this.comboBoxCategory_DropDown);
this.comboBoxCategory.DroppedDown = true;
this.comboBoxCategory.DropDown += new System.EventHandler(this.comboBoxCategory_DropDown);
//if( this.treeViewCategory.Visible == true )
//{
// return;//在显示TreeView的情况下
//}
this.treeViewCategory.Visible = !this.treeViewCategory.Visible;
}
{
ListItem items = new ListItem();
items.Text = "无";
items.Value ="-1";
this.DropDownList1.Items.Add(items);
//得到所有设备名称:
DataSet ds = SqlHelper.ExecuteDataset(connstr, CommandType.Text,
"select ID,Name,PID from SDTZ_EquipmentType"); dt = ds.Tables[0]; //第一层加载(ID为-1)
DataRow[] drs = dt.Select("PID=-1");
for (int i = 0; i < drs.Length; i++)
{
string name = drs[i][1].ToString();
int id = Convert.ToInt32(drs[i][0]); this.DropDownList1.Items.Add(name);
this.DropDownList1.Items[this.DropDownList1.Items.Count - 1].Value = id.ToString();
j = 0;
LoadTree(id);
}
}
int j = 0;
//递归函数:
private void LoadTree(int typeid)
{
string test = "";
DataRow[] drs = dt.Select("PID=" + typeid + ""); if (drs != null)
{
j++;
for (int i = 0; i < j; i++)
{
test = test + "|-";
}
for (int i = 0; i < drs.Length; i++)
{
this.DropDownList1.Items.Add(test + drs[i][1].ToString());
this.DropDownList1.Items[this.DropDownList1.Items.Count - 1].Value = drs[i][0].ToString(); LoadTree(Convert.ToInt32(drs[i][0]));
}
}
}