扩展控件问题?
我想扩展treeview控件。请问是不是这样做的~~
打开vs20003。新建项目windos控件库。
模版为我生成了public class UserControl1 : System.Windows.Forms.UserControl
我改成了public class MyTreeView : System.Windows.Forms.Treeview.
里面还有个窗体设计器。是不是在这里面设计控件的样式?但我想就用treeview的样式。请问怎么实现~
还是根本扩展控件的功能不是这样的步走?请高手指教~~
问题点数:20、回复次数:1Top
1 楼syfsz(黄金分割点)回复于 2005-09-27 03:44:51 得分 20
这个是封装 微软的 WebControls 里的 TreeView 的:
using System;
using System.Drawing;
using Microsoft.Web.UI.WebControls;
namespace RunTimeWebControls
{
/// <summary>
/// Summary description for WebTreeView.
/// </summary>
[ToolboxBitmap(typeof(System.Windows.Forms.TreeView))]
public class WebTreeView:TreeView
{
public WebTreeView()
{
this.SystemImagesPath = "/webctrl_client/1_0/treeimages/";
this.AutoPostBack = true;
this.AutoSelect = true;
this.ShowLines=true;
this.ShowPlus = true;
this.BorderWidth=2;
this.BorderStyle = System.Web.UI.WebControls.BorderStyle.Inset;
}
public void ExpandAll()
{
foreach (TreeNode loNode in this.Nodes)
{
ExpandChild(loNode);
}
}
public TreeNode GetSelectedNode()
{
return this.GetNodeFromIndex(this.SelectedNodeIndex);
}
public static void ExpandChild(TreeNode poNode)
{
if (poNode!=null&&poNode.Nodes.Count>0)
{
poNode.Expanded = true;
foreach (TreeNode loNode in poNode.Nodes)
ExpandChild(loNode);
}
}
}
}
Top




