.net树形控件的这种效果是怎么做出来的?
展开全部
如果是对 TreeView 实现的话,主要是自定义绘制节点,类似这样
private void tvSample_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
string text = string.Empty;
if (e.Node.Level == 0)
{
e.DrawDefault = true;
return;
}
else if (e.Node.Parent.Nodes.IndexOf(e.Node) < e.Node.Parent.Nodes.Count - 1)
text = new string(' ', e.Node.Level * 2) + "├" + e.Node.Text;
else
text = new string(' ', e.Node.Level * 2) + "└" + e.Node.Text;
e.Graphics.DrawString(text, tvSample.Font, Brushes.Black, Rectangle.Inflate(e.Bounds, 2, 0));
}
从图上看这控件,更像是 asp.net 的 devexpress
private void tvSample_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
string text = string.Empty;
if (e.Node.Level == 0)
{
e.DrawDefault = true;
return;
}
else if (e.Node.Parent.Nodes.IndexOf(e.Node) < e.Node.Parent.Nodes.Count - 1)
text = new string(' ', e.Node.Level * 2) + "├" + e.Node.Text;
else
text = new string(' ', e.Node.Level * 2) + "└" + e.Node.Text;
e.Graphics.DrawString(text, tvSample.Font, Brushes.Black, Rectangle.Inflate(e.Bounds, 2, 0));
}
从图上看这控件,更像是 asp.net 的 devexpress
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询