当前位置:编程学习 > C#/ASP.NET >>

请问这个button怎么没有移动呢?


设置Panel1的AutoScroll属性为true

 public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }           
        private void Form1_Load(object sender, EventArgs e)
        {
            Button button3 = new Button();
            button3.Text = "button3";
            button3.Location = new Point(300,30);
            panel1.Controls.Add(button3);

            foreach (Control c in panel1.Controls)
            {
                if (c is Button && c.Text == "button3")
                {
                    c.AutoScrollOffset = new Point(100, c.Location.Y);  //关于AutoScrollOffset,见MSDN
                    panel1.ScrollControlIntoView(c as Button);  //关于ScrollControlIntoView,见MSDN                    break;
                }
            }
         }
    }

滚动条怎么没有自动滚动呢?我设置了设置Panel1的AutoScroll属性为true
--------------------编程问答-------------------- 等待答案 --------------------编程问答-------------------- 为什么要移动
你给了它什么事件   
--------------------编程问答--------------------
引用 2 楼 fengyarongaa 的回复:
为什么要移动
你给了它什么事件

为什么不移动 --------------------编程问答-------------------- ???....button3肯定移动了 只不过刚建立就移动到别的地方了,移动速度非常快 你的眼睛看不出来 --------------------编程问答--------------------
引用 4 楼 flyforfei 的回复:
???....button3肯定移动了 只不过刚建立就移动到别的地方了,移动速度非常快 你的眼睛看不出来

移动了?那应该在panel的视图中吧,可是没看见 --------------------编程问答-------------------- 首先你的panel必须已经出现滚动条才行 --------------------编程问答--------------------
引用 6 楼 bdmh 的回复:
首先你的panel必须已经出现滚动条才行

出现了啊 --------------------编程问答-------------------- 是要上下移动么,
你先将c.AutoScrollOffset = new Point(100, 100); 
固定,再看(100,100)有木有
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,