做类似QQ图象跳动功能
我想到两种方法
1、动态更换treeview节点上的图象
2、更换treeview节点上图象的坐标目前我想采用第2种
但不知道怎么做
请高人帮忙

解决方案 »

  1.   

    参考如下代码
    /// <summary>
    /// 偏移的序号
    /// </summary>
    private int flashIndex = -1;  
    /// <summary>
    /// 偏移的坐标集
    /// </summary>
    private Point[] pointFlashs = new Point[] { 
        new Point(0, +1), new Point(0, -1), 
        new Point(+1, 0), new Point(-1, 0) }; 
    private void timer1_Tick(object sender, EventArgs e)
    {
        TreeNode vTreeNode = treeView1.SelectedNode;
        if (vTreeNode == null) // 无节点处理
        {
            if (flashIndex >= 0)
            {
                treeView1.Refresh();
                flashIndex = -1;
            }
            return;
        }
        if (!vTreeNode.IsVisible) return; // 不可见
        if (flashIndex < 0) flashIndex = 0;
        Graphics vGraphics = treeView1.CreateGraphics();
        Rectangle vRectangle = new Rectangle(
            vTreeNode.Bounds.Left - imageList1.ImageSize.Width - 3,
            vTreeNode.Bounds.Top, imageList1.ImageSize.Width, imageList1.ImageSize.Height
        );
        vGraphics.FillRectangle(new SolidBrush(treeView1.BackColor), vRectangle);
        int vImageIndex = vTreeNode.ImageIndex;
        if (vImageIndex < 0) vImageIndex = 0;
        imageList1.Draw(vGraphics, 
            vRectangle.Left + pointFlashs[flashIndex].X,
            vRectangle.Top + pointFlashs[flashIndex].Y, vImageIndex);
        vGraphics.Dispose();
        flashIndex = (flashIndex + 1) % pointFlashs.Length;
    }
      

  2.   

    今天来揭贴   
    想不到有人回贴了
    我周一再来试
    zswang 的方法
    谢谢你